mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2024-11-14 23:00:22 +01:00
116 lines
3.1 KiB
Lua
116 lines
3.1 KiB
Lua
local mtsettings = minetest.settings
|
|
local settings = Settings(minetest.get_worldpath() .. '/mapgen_rivers.conf')
|
|
|
|
mapgen_rivers.version = "1.0.2"
|
|
mapgen_rivers.settings = settings
|
|
|
|
local previous_version_mt = mtsettings:get("mapgen_rivers_version") or "0.0"
|
|
local previous_version_mgr = settings:get("version") or "0.0"
|
|
|
|
if mapgen_rivers.version ~= previous_version_mt or mapgen_rivers.version ~= previous_version_mgr then
|
|
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(settings)
|
|
end
|
|
end
|
|
|
|
mtsettings:set("mapgen_rivers_version", mapgen_rivers.version)
|
|
settings:set("version", mapgen_rivers.version)
|
|
|
|
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)
|
|
if dtype == "number" or dtype == "string" then
|
|
if mthas then
|
|
v = mtsettings:get(mtname)
|
|
if dtype == "number" and tonumber(v) == nil then
|
|
v = default
|
|
end
|
|
end
|
|
settings:set(name, v)
|
|
elseif dtype == "bool" then
|
|
if mthas then
|
|
v = mtsettings:get(mtname)
|
|
end
|
|
settings:set_bool(name, v)
|
|
elseif dtype == "noise" then
|
|
if mthas then
|
|
v = mtsettings:get_np_group(mtname)
|
|
end
|
|
settings:set_np_group(name, v)
|
|
end
|
|
end
|
|
|
|
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)
|
|
|
|
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",
|
|
})
|
|
|
|
if modified then
|
|
settings:write()
|
|
end
|