2021-06-06 13:25:43 +02:00
|
|
|
local mtsettings = minetest.settings
|
|
|
|
local mgrsettings = Settings(minetest.get_worldpath() .. '/mapgen_rivers.conf')
|
2021-07-24 13:21:06 +02:00
|
|
|
|
2021-09-14 15:07:11 +02:00
|
|
|
mapgen_rivers.version = "1.0.1"
|
2021-07-24 13:21:06 +02:00
|
|
|
|
|
|
|
local previous_version_mt = mtsettings:get("mapgen_rivers_version") or "0.0"
|
|
|
|
local previous_version_mgr = mgrsettings:get("version") or "0.0"
|
|
|
|
|
|
|
|
if mapgen_rivers.version ~= previous_version_mt or mapgen_rivers.version ~= previous_version_mgr then
|
2021-07-24 18:55:13 +02:00
|
|
|
local compat_mt, compat_mgr = dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/compatibility.lua")
|
|
|
|
if mapgen_rivers.version ~= previous_version_mt then
|
|
|
|
compat_mt(mtsettings)
|
|
|
|
end
|
|
|
|
if mapgen_rivers.version ~= previous_version_mgr then
|
|
|
|
compat_mgr(mgrsettings)
|
|
|
|
end
|
2021-07-24 13:21:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
mtsettings:set("mapgen_rivers_version", mapgen_rivers.version)
|
|
|
|
mgrsettings:set("version", mapgen_rivers.version)
|
|
|
|
|
2021-06-06 13:25:43 +02:00
|
|
|
function mapgen_rivers.define_setting(name, dtype, default)
|
|
|
|
if dtype == "number" or dtype == "string" then
|
|
|
|
local v = mgrsettings:get(name)
|
|
|
|
if v == nil then
|
|
|
|
v = mtsettings:get('mapgen_rivers_' .. name)
|
|
|
|
if v == nil then
|
|
|
|
v = default
|
|
|
|
end
|
|
|
|
mgrsettings:set(name, v)
|
2020-04-14 17:53:36 +02:00
|
|
|
end
|
2021-06-06 13:25:43 +02:00
|
|
|
if dtype == "number" then
|
|
|
|
return tonumber(v)
|
2020-11-17 20:56:02 +01:00
|
|
|
else
|
2021-06-06 13:25:43 +02:00
|
|
|
return v
|
|
|
|
end
|
|
|
|
elseif dtype == "bool" then
|
|
|
|
local v = mgrsettings:get_bool(name)
|
|
|
|
if v == nil then
|
|
|
|
v = mtsettings:get_bool('mapgen_rivers_' .. name)
|
|
|
|
if v == nil then
|
|
|
|
v = default
|
2020-11-17 20:56:02 +01:00
|
|
|
end
|
2021-06-06 13:25:43 +02:00
|
|
|
mgrsettings:set_bool(name, v)
|
2020-04-14 17:53:36 +02:00
|
|
|
end
|
2021-06-06 13:25:43 +02:00
|
|
|
return v
|
|
|
|
elseif dtype == "noise" then
|
|
|
|
local v = mgrsettings:get_np_group(name)
|
|
|
|
if v == nil then
|
|
|
|
v = mtsettings:get_np_group('mapgen_rivers_' .. name)
|
|
|
|
if v == nil then
|
|
|
|
v = default
|
|
|
|
end
|
|
|
|
mgrsettings:set_np_group(name, v)
|
2020-04-14 17:53:36 +02:00
|
|
|
end
|
2021-06-06 13:25:43 +02:00
|
|
|
return v
|
2020-04-14 17:53:36 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-06-06 13:25:43 +02:00
|
|
|
local def_setting = mapgen_rivers.define_setting
|
|
|
|
|
|
|
|
mapgen_rivers.settings = {
|
2021-06-25 21:03:33 +02:00
|
|
|
center = def_setting('center', 'bool', true),
|
2021-07-24 10:23:06 +02:00
|
|
|
blocksize = def_setting('blocksize', 'number', 15),
|
2021-06-06 13:25:43 +02:00
|
|
|
sea_level = tonumber(minetest.get_mapgen_setting('water_level')),
|
2021-07-24 13:18:58 +02:00
|
|
|
min_catchment = def_setting('min_catchment', 'number', 3600),
|
|
|
|
river_widening_power = def_setting('river_widening_power', 'number', 0.5),
|
2021-06-06 13:25:43 +02:00
|
|
|
riverbed_slope = def_setting('riverbed_slope', 'number', 0.4),
|
|
|
|
distort = def_setting('distort', 'bool', true),
|
|
|
|
biomes = def_setting('biomes', 'bool', true),
|
|
|
|
glaciers = def_setting('glaciers', 'bool', false),
|
|
|
|
glacier_factor = def_setting('glacier_factor', 'number', 8),
|
|
|
|
elevation_chill = def_setting('elevation_chill', 'number', 0.25),
|
|
|
|
|
2021-07-24 18:55:13 +02:00
|
|
|
grid_x_size = def_setting('grid_x_size', 'number', 1000),
|
|
|
|
grid_z_size = def_setting('grid_z_size', 'number', 1000),
|
2021-06-06 13:25:43 +02:00
|
|
|
evol_params = {
|
|
|
|
K = def_setting('river_erosion_coef', 'number', 0.5),
|
|
|
|
m = def_setting('river_erosion_power', 'number', 0.4),
|
|
|
|
d = def_setting('diffusive_erosion', 'number', 0.5),
|
2021-07-24 10:23:06 +02:00
|
|
|
compensation_radius = def_setting('compensation_radius', 'number', 50),
|
2021-06-06 13:25:43 +02:00
|
|
|
},
|
|
|
|
tectonic_speed = def_setting('tectonic_speed', 'number', 70),
|
|
|
|
evol_time = def_setting('evol_time', 'number', 10),
|
|
|
|
evol_time_step = def_setting('evol_time_step', 'number', 1),
|
2021-06-26 13:13:41 +02:00
|
|
|
|
2021-07-24 18:55:13 +02:00
|
|
|
load_all = mtsettings:get_bool('mapgen_rivers_load_all')
|
2021-06-06 13:25:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
local function write_settings()
|
|
|
|
mgrsettings:write()
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_on_mods_loaded(write_settings)
|
|
|
|
minetest.register_on_shutdown(write_settings)
|