mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2024-11-14 23:00:22 +01:00
44 lines
1.2 KiB
Lua
44 lines
1.2 KiB
Lua
mapgen_rivers = {}
|
|
|
|
if minetest.get_mapgen_setting("mg_name") ~= "singlenode" then
|
|
minetest.set_mapgen_setting("mg_name", "singlenode", true)
|
|
minetest.log("warning", "[mapgen_rivers] Mapgen set to singlenode")
|
|
end
|
|
|
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
|
dofile(modpath .. '/settings.lua')
|
|
|
|
local sfile = io.open(minetest.get_worldpath() .. '/river_data/size')
|
|
if sfile then
|
|
sfile:close()
|
|
else
|
|
dofile(modpath .. '/pregenerate.lua')
|
|
collectgarbage()
|
|
end
|
|
|
|
mapgen_rivers.use_mapgen_thread = minetest.settings:get_bool("mapgen_rivers_use_mapgen_thread")
|
|
mapgen_rivers.thread = 'main'
|
|
if mapgen_rivers.use_mapgen_thread then
|
|
if minetest.register_mapgen_dofile then
|
|
minetest.register_mapgen_dofile(modpath .. '/mapgen.lua')
|
|
else
|
|
minetest.log("warning", "[mapgen_rivers] Mapgen thread not available on this Minetest version.")
|
|
mapgen_rivers.use_mapgen_thread = false
|
|
end
|
|
end
|
|
|
|
if not mapgen_rivers.use_mapgen_thread then
|
|
dofile(modpath .. '/mapgen.lua')
|
|
end
|
|
|
|
-- Setup a metatable to load grid on request if not present
|
|
local mt = {
|
|
__index = function(_, field)
|
|
if field == 'grid' then
|
|
dofile(modpath .. '/load_grid.lua')
|
|
return mapgen_rivers.grid
|
|
end
|
|
end,
|
|
}
|
|
setmetatable(mapgen_rivers, mt)
|