2021-06-06 13:25:43 +02:00
|
|
|
local mtsettings = minetest.settings
|
2024-01-04 22:47:50 +01:00
|
|
|
local settings = Settings(minetest.get_worldpath() .. '/mapgen_rivers.conf')
|
2021-07-24 13:21:06 +02:00
|
|
|
|
2022-01-10 12:44:33 +01:00
|
|
|
mapgen_rivers.version = "1.0.2"
|
2023-12-30 17:38:51 +01:00
|
|
|
mapgen_rivers.settings = settings
|
2021-07-24 13:21:06 +02:00
|
|
|
|
|
|
|
local previous_version_mt = mtsettings:get("mapgen_rivers_version") or "0.0"
|
2024-01-04 22:47:50 +01:00
|
|
|
local previous_version_mgr = settings:get("version") or "0.0"
|
2021-07-24 13:21:06 +02:00
|
|
|
|
|
|
|
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
|
2024-01-04 22:47:50 +01:00
|
|
|
compat_mgr(settings)
|
2021-07-24 18:55:13 +02:00
|
|
|
end
|
2021-07-24 13:21:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
mtsettings:set("mapgen_rivers_version", mapgen_rivers.version)
|
2024-01-04 22:47:50 +01:00
|
|
|
settings:set("version", mapgen_rivers.version)
|
2021-07-24 13:21:06 +02:00
|
|
|
|
2024-01-04 22:47:50 +01:00
|
|
|
local modified = false
|
|
|
|
local function verify_setting(name, dtype, default)
|
|
|
|
if settings:has(name) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
modified = true
|
|
|
|
local v = default
|
|
|
|
local mtname = 'mapgen_rivers_' .. name
|
|
|
|
local mthas = mtsettings:has(mtname)
|
2021-06-06 13:25:43 +02:00
|
|
|
if dtype == "number" or dtype == "string" then
|
2024-01-04 22:47:50 +01:00
|
|
|
if mthas then
|
|
|
|
v = mtsettings:get(mtname)
|
|
|
|
if dtype == "number" and tonumber(v) == nil then
|
2021-06-06 13:25:43 +02:00
|
|
|
v = default
|
|
|
|
end
|
|
|
|
end
|
2024-01-04 22:47:50 +01:00
|
|
|
settings:set(name, v)
|
2021-06-06 13:25:43 +02:00
|
|
|
elseif dtype == "bool" then
|
2024-01-04 22:47:50 +01:00
|
|
|
if mthas then
|
|
|
|
v = mtsettings:get(mtname)
|
2020-04-14 17:53:36 +02:00
|
|
|
end
|
2024-01-04 22:47:50 +01:00
|
|
|
settings:set_bool(name, v)
|
2024-01-04 23:28:33 +01:00
|
|
|
elseif dtype == "noise" then
|
2024-01-04 22:47:50 +01:00
|
|
|
if mthas then
|
|
|
|
v = mtsettings:get_np_group(mtname)
|
2020-04-14 17:53:36 +02:00
|
|
|
end
|
2024-01-04 22:47:50 +01:00
|
|
|
settings:set_np_group(name, v)
|
2020-04-14 17:53:36 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-01-04 22:47:50 +01:00
|
|
|
verify_setting('center', 'bool', true)
|
|
|
|
verify_setting('blocksize', 'number', 15)
|
|
|
|
verify_setting('min_catchment', 'number', 3600)
|
|
|
|
verify_setting('river_widening_power', 'number', 0.5)
|
|
|
|
verify_setting('riverbed_slope', 'number', 0.4)
|
|
|
|
verify_setting('distort', 'bool', true)
|
|
|
|
verify_setting('biomes', 'bool', true)
|
|
|
|
verify_setting('glaciers', 'bool', false)
|
|
|
|
verify_setting('glacier_factor', 'number', 8)
|
|
|
|
verify_setting('elevation_chill', 'number', 0.25)
|
|
|
|
verify_setting('grid_x_size', 'number', 1000)
|
|
|
|
verify_setting('grid_z_size', 'number', 1000)
|
|
|
|
verify_setting('river_erosion_coef', 'number', 0.5)
|
|
|
|
verify_setting('river_erosion_power', 'number', 0.4)
|
|
|
|
verify_setting('diffusive_erosion', 'number', 0.5)
|
|
|
|
verify_setting('compensation_radius', 'number', 50)
|
|
|
|
verify_setting('tectonic_speed', 'number', 70)
|
|
|
|
verify_setting('evol_time', 'number', 10)
|
|
|
|
verify_setting('evol_time_step', 'number', 1)
|
2021-06-26 13:13:41 +02:00
|
|
|
|
2024-01-04 22:47:50 +01:00
|
|
|
verify_setting('np_base', 'noise', {
|
|
|
|
offset = 0,
|
|
|
|
scale = 300,
|
|
|
|
seed = 2469,
|
|
|
|
octaves = 8,
|
|
|
|
spread = {x=2048, y=2048, z=2048},
|
|
|
|
persist = 0.6,
|
|
|
|
lacunarity = 2,
|
|
|
|
flags = "eased",
|
|
|
|
})
|
|
|
|
verify_setting('np_distort_x', 'noise', {
|
|
|
|
offset = 0,
|
|
|
|
scale = 1,
|
|
|
|
seed = -4574,
|
|
|
|
spread = {x=64, y=32, z=64},
|
|
|
|
octaves = 3,
|
|
|
|
persistence = 0.75,
|
|
|
|
lacunarity = 2,
|
|
|
|
})
|
|
|
|
verify_setting('np_distort_z', 'noise', {
|
|
|
|
offset = 0,
|
|
|
|
scale = 1,
|
|
|
|
seed = -7940,
|
|
|
|
spread = {x=64, y=32, z=64},
|
|
|
|
octaves = 3,
|
|
|
|
persistence = 0.75,
|
|
|
|
lacunarity = 2,
|
|
|
|
})
|
|
|
|
verify_setting('np_distort_amplitude', 'noise', {
|
|
|
|
offset = 0,
|
|
|
|
scale = 10,
|
|
|
|
seed = 676,
|
|
|
|
spread = {x=1024, y=1024, z=1024},
|
|
|
|
octaves = 5,
|
|
|
|
persistence = 0.5,
|
|
|
|
lacunarity = 2,
|
|
|
|
flags = "absvalue",
|
|
|
|
})
|
2021-06-06 13:25:43 +02:00
|
|
|
|
2024-01-04 22:47:50 +01:00
|
|
|
if modified then
|
|
|
|
settings:write()
|
|
|
|
end
|