2020-04-14 17:53:36 +02:00
|
|
|
local storage = minetest.get_mod_storage()
|
|
|
|
local settings = minetest.settings
|
|
|
|
|
|
|
|
local function get_settings(key, dtype, default)
|
|
|
|
if storage:contains(key) then
|
|
|
|
if dtype == "string" then
|
|
|
|
return storage:get_string(key)
|
|
|
|
elseif dtype == "int" then
|
|
|
|
return storage:get_int(key)
|
|
|
|
elseif dtype == "float" then
|
|
|
|
return storage:get_float(key)
|
2020-05-24 11:38:47 +02:00
|
|
|
elseif dtype == "bool" then
|
|
|
|
return storage:get_string(key) == 'true'
|
2020-04-14 17:53:36 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local conf_val = settings:get('mapgen_rivers_' .. key)
|
|
|
|
if conf_val then
|
|
|
|
if dtype == "int" then
|
|
|
|
conf_val = tonumber(conf_val)
|
|
|
|
storage:set_int(key, conf_val)
|
|
|
|
elseif dtype == "float" then
|
|
|
|
conf_val = tonumber(conf_val)
|
|
|
|
storage:set_float(key, conf_val)
|
2020-11-17 20:56:02 +01:00
|
|
|
else
|
2020-04-14 17:53:36 +02:00
|
|
|
storage:set_string(key, conf_val)
|
2020-11-17 20:56:02 +01:00
|
|
|
if dtype == "bool" then
|
|
|
|
conf_val = conf_val == 'true'
|
|
|
|
end
|
2020-04-14 17:53:36 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return conf_val
|
|
|
|
else
|
|
|
|
if dtype == "int" then
|
|
|
|
storage:set_int(key, default)
|
|
|
|
elseif dtype == "float" then
|
|
|
|
storage:set_float(key, default)
|
|
|
|
elseif dtype == "string" then
|
|
|
|
storage:set_string(key, default)
|
2020-05-24 11:38:47 +02:00
|
|
|
elseif dtype == "bool" then
|
|
|
|
storage:set_string(key, tostring(default))
|
2020-04-14 17:53:36 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return default
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-14 21:11:54 +02:00
|
|
|
mapgen_rivers.blocksize = get_settings('blocksize', 'int', 12)
|
|
|
|
mapgen_rivers.sea_level = get_settings('sea_level', 'int', 1)
|
|
|
|
mapgen_rivers.min_catchment = get_settings('min_catchment', 'float', 25)
|
|
|
|
mapgen_rivers.max_catchment = get_settings('max_catchment', 'float', 40000)
|
|
|
|
mapgen_rivers.riverbed_slope = get_settings('riverbed_slope', 'float', 0.4) * mapgen_rivers.blocksize
|
2020-07-21 14:01:29 +02:00
|
|
|
mapgen_rivers.distort = get_settings('distort', 'bool', true)
|
2020-11-10 13:25:04 +01:00
|
|
|
mapgen_rivers.biomes = get_settings('biomes', 'bool', true)
|
2020-11-15 11:26:50 +01:00
|
|
|
mapgen_rivers.glaciers = get_settings('glaciers', 'bool', false)
|
2020-05-24 11:38:47 +02:00
|
|
|
mapgen_rivers.glacier_factor = get_settings('glacier_factor', 'float', 8)
|
|
|
|
mapgen_rivers.elevation_chill = get_settings('elevation_chill', 'float', 0.25)
|