2020-04-14 21:11:54 +02:00
|
|
|
mapgen_rivers = {}
|
2020-04-09 21:13:38 +02:00
|
|
|
|
2021-09-07 11:59:33 +02:00
|
|
|
if minetest.get_mapgen_setting("mg_name") ~= "singlenode" then
|
|
|
|
minetest.set_mapgen_setting("mg_name", "singlenode", true)
|
2022-01-03 16:22:55 +01:00
|
|
|
minetest.log("warning", "[mapgen_rivers] Mapgen set to singlenode")
|
2021-09-07 11:59:33 +02:00
|
|
|
end
|
|
|
|
|
2024-01-04 23:28:33 +01:00
|
|
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
|
|
|
dofile(modpath .. '/settings.lua')
|
2020-04-09 21:13:38 +02:00
|
|
|
|
2024-01-04 22:47:50 +01:00
|
|
|
local sfile = io.open(minetest.get_worldpath() .. '/river_data/size')
|
2023-12-28 15:27:36 +01:00
|
|
|
if sfile then
|
|
|
|
sfile:close()
|
|
|
|
else
|
2024-01-04 23:28:33 +01:00
|
|
|
dofile(modpath .. '/pregenerate.lua')
|
2023-12-28 15:27:36 +01:00
|
|
|
collectgarbage()
|
2020-11-10 13:25:04 +01:00
|
|
|
end
|
2020-05-23 15:52:16 +02:00
|
|
|
|
2023-12-28 15:27:36 +01:00
|
|
|
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')
|
2020-04-09 21:13:38 +02:00
|
|
|
end
|
|
|
|
|
2023-12-28 15:27:36 +01:00
|
|
|
-- 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')
|
2023-12-28 15:27:36 +01:00
|
|
|
return mapgen_rivers.grid
|
2020-07-21 14:01:29 +02:00
|
|
|
end
|
2023-12-28 15:27:36 +01:00
|
|
|
end,
|
|
|
|
}
|
|
|
|
setmetatable(mapgen_rivers, mt)
|