mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2025-01-01 14:00:36 +01:00
6564d40b85
Move grid management functions out of polygons.lua, in a new file called gridmanager.lua Explicitly call other files and grid management functions from init.lua to make workflow more apparent Move mapgen loop out of init.lua, into mapgen.lua
25 lines
745 B
Lua
25 lines
745 B
Lua
mapgen_rivers = {}
|
|
|
|
local modpath = minetest.get_modpath(minetest.get_current_modname()) .. '/'
|
|
mapgen_rivers.modpath = modpath
|
|
mapgen_rivers.world_data_path = minetest.get_worldpath() .. '/river_data/'
|
|
|
|
dofile(modpath .. 'settings.lua')
|
|
dofile(modpath .. 'gridmanager.lua')
|
|
dofile(modpath .. 'gridio.lua')
|
|
dofile(modpath .. 'polygons.lua')
|
|
dofile(modpath .. 'heightmap.lua')
|
|
dofile(modpath .. 'mapgen.lua')
|
|
|
|
minetest.register_on_mods_loaded(function()
|
|
local exist = mapgen_rivers.try_load_grid()
|
|
|
|
if not exist then -- If grid does not exist yet, generate it
|
|
dofile(modpath .. 'pregenerate.lua')
|
|
|
|
local grid = mapgen_rivers.generate_grid()
|
|
mapgen_rivers.write_grid(grid)
|
|
mapgen_rivers.try_load_grid(grid) -- Reload if needed
|
|
end
|
|
end)
|