mapgen_rivers/init.lua

44 lines
1.2 KiB
Lua
Raw Normal View History

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
2024-01-04 23:28:33 +01:00
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
2024-01-04 23:28:33 +01:00
dofile(modpath .. '/pregenerate.lua')
collectgarbage()
2020-11-10 13:25:04 +01:00
end
mapgen_rivers.use_mapgen_thread = minetest.settings:get_bool("mapgen_rivers_use_mapgen_thread")
mapgen_rivers.thread = 'main'
2024-01-04 23:28:33 +01:00
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
2024-01-04 23:28:33 +01:00
dofile(modpath .. '/load_grid.lua')
return mapgen_rivers.grid
end
end,
}
setmetatable(mapgen_rivers, mt)