mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2024-12-28 03:40:39 +01:00
Globalize some of the main functions
This will allow to avoid nested 'dofile's
This commit is contained in:
parent
b0930f4d40
commit
cd2a77803f
@ -1,6 +1,5 @@
|
||||
local modpath = mapgen_rivers.modpath
|
||||
|
||||
local make_polygons = dofile(modpath .. 'polygons.lua')
|
||||
local transform_quadri = dofile(modpath .. 'geometry.lua')
|
||||
|
||||
local sea_level = mapgen_rivers.settings.sea_level
|
||||
@ -19,9 +18,9 @@ local function interp(v00, v01, v11, v10, xf, zf)
|
||||
return v1*zf + v0*(1-zf)
|
||||
end
|
||||
|
||||
local function heightmaps(minp, maxp)
|
||||
function mapgen_rivers.make_heightmaps(minp, maxp)
|
||||
|
||||
local polygons = make_polygons(minp, maxp)
|
||||
local polygons = mapgen_rivers.make_polygons(minp, maxp)
|
||||
local incr = maxp.z-minp.z+1
|
||||
|
||||
local terrain_height_map = {}
|
||||
@ -144,5 +143,3 @@ local function heightmaps(minp, maxp)
|
||||
|
||||
return terrain_height_map, lake_height_map
|
||||
end
|
||||
|
||||
return heightmaps
|
||||
|
8
init.lua
8
init.lua
@ -10,6 +10,8 @@ if minetest.get_mapgen_setting("mg_name") ~= "singlenode" then
|
||||
end
|
||||
|
||||
dofile(modpath .. 'settings.lua')
|
||||
dofile(modpath .. 'polygons.lua')
|
||||
dofile(modpath .. 'heightmap.lua')
|
||||
|
||||
local sea_level = mapgen_rivers.settings.sea_level
|
||||
local elevation_chill = mapgen_rivers.settings.elevation_chill
|
||||
@ -22,8 +24,6 @@ if use_biomegen_mod then
|
||||
biomegen.set_elevation_chill(elevation_chill)
|
||||
end
|
||||
|
||||
local heightmaps = dofile(modpath .. 'heightmap.lua')
|
||||
|
||||
-- Linear interpolation
|
||||
local function interp(v00, v01, v11, v10, xf, zf)
|
||||
local v0 = v01*xf + v00*(1-xf)
|
||||
@ -117,9 +117,9 @@ local function generate(minp, maxp, seed)
|
||||
local pmaxp = {x=floor(xmax)+1, z=floor(zmax)+1}
|
||||
incr = pmaxp.x-pminp.x+1
|
||||
i_origin = 1 - pminp.z*incr - pminp.x
|
||||
terrain_map, lake_map = heightmaps(pminp, pmaxp)
|
||||
terrain_map, lake_map = mapgen_rivers.make_heightmaps(pminp, pmaxp)
|
||||
else
|
||||
terrain_map, lake_map = heightmaps(minp, maxp)
|
||||
terrain_map, lake_map = mapgen_rivers.make_heightmaps(minp, maxp)
|
||||
end
|
||||
|
||||
-- Check that there is at least one position that reaches min y
|
||||
|
@ -119,7 +119,7 @@ local init = false
|
||||
|
||||
-- On map generation, determine into which polygon every point (in 2D) will fall.
|
||||
-- Also store polygon-specific data
|
||||
local function make_polygons(minp, maxp)
|
||||
function mapgen_rivers.make_polygons(minp, maxp)
|
||||
|
||||
local grid = mapgen_rivers.grid
|
||||
local dem = grid.dem
|
||||
@ -252,5 +252,3 @@ local function make_polygons(minp, maxp)
|
||||
|
||||
return polygons
|
||||
end
|
||||
|
||||
return make_polygons
|
||||
|
Loading…
Reference in New Issue
Block a user