mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2024-12-28 03:40:39 +01:00
Code style consistency: use tabs for indentation in all Lua code
This commit is contained in:
parent
95e87f8820
commit
2c5e0ee5af
@ -1,34 +1,34 @@
|
||||
local function fix_min_catchment(settings, is_global)
|
||||
local prefix = is_global and "mapgen_rivers_" or ""
|
||||
local prefix = is_global and "mapgen_rivers_" or ""
|
||||
|
||||
local min_catchment = settings:get(prefix.."min_catchment")
|
||||
if min_catchment then
|
||||
min_catchment = tonumber(min_catchment)
|
||||
local blocksize = tonumber(settings:get(prefix.."blocksize") or 15)
|
||||
settings:set(prefix.."min_catchment", tonumber(min_catchment) * blocksize*blocksize)
|
||||
local max_catchment = settings:get(prefix.."max_catchment")
|
||||
if max_catchment then
|
||||
max_catchment = tonumber(max_catchment)
|
||||
local wpower = math.log(2*blocksize)/math.log(max_catchment/min_catchment)
|
||||
settings:set(prefix.."river_widening_power", wpower)
|
||||
end
|
||||
end
|
||||
local min_catchment = settings:get(prefix.."min_catchment")
|
||||
if min_catchment then
|
||||
min_catchment = tonumber(min_catchment)
|
||||
local blocksize = tonumber(settings:get(prefix.."blocksize") or 15)
|
||||
settings:set(prefix.."min_catchment", tonumber(min_catchment) * blocksize*blocksize)
|
||||
local max_catchment = settings:get(prefix.."max_catchment")
|
||||
if max_catchment then
|
||||
max_catchment = tonumber(max_catchment)
|
||||
local wpower = math.log(2*blocksize)/math.log(max_catchment/min_catchment)
|
||||
settings:set(prefix.."river_widening_power", wpower)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function fix_compatibility_minetest(settings)
|
||||
local previous_version = settings:get("mapgen_rivers_version") or "0.0"
|
||||
local previous_version = settings:get("mapgen_rivers_version") or "0.0"
|
||||
|
||||
if previous_version == "0.0" then
|
||||
fix_min_catchment(settings, true)
|
||||
end
|
||||
if previous_version == "0.0" then
|
||||
fix_min_catchment(settings, true)
|
||||
end
|
||||
end
|
||||
|
||||
local function fix_compatibility_mapgen_rivers(settings)
|
||||
local previous_version = settings:get("version") or "0.0"
|
||||
local previous_version = settings:get("version") or "0.0"
|
||||
|
||||
if previous_version == "0.0" then
|
||||
fix_min_catchment(settings, false)
|
||||
end
|
||||
if previous_version == "0.0" then
|
||||
fix_min_catchment(settings, false)
|
||||
end
|
||||
end
|
||||
|
||||
return fix_compatibility_minetest, fix_compatibility_mapgen_rivers
|
||||
|
40
load.lua
40
load.lua
@ -73,28 +73,28 @@ function mapgen_rivers.interactive_loader(filename, bytes, signed, size, convert
|
||||
end
|
||||
|
||||
function mapgen_rivers.write_map(filename, data, bytes)
|
||||
local size = #data
|
||||
local file = io.open(worldpath .. filename, 'wb')
|
||||
local mfloor = math.floor
|
||||
local schar = string.char
|
||||
local upack = unpack
|
||||
local size = #data
|
||||
local file = io.open(worldpath .. filename, 'wb')
|
||||
local mfloor = math.floor
|
||||
local schar = string.char
|
||||
local upack = unpack
|
||||
|
||||
local bytelist = {}
|
||||
for j=1, bytes do
|
||||
bytelist[j] = 0
|
||||
end
|
||||
local bytelist = {}
|
||||
for j=1, bytes do
|
||||
bytelist[j] = 0
|
||||
end
|
||||
|
||||
for i=1, size do
|
||||
local n = mfloor(data[i])
|
||||
data[i] = n
|
||||
for j=bytes, 2, -1 do
|
||||
bytelist[j] = n % 256
|
||||
n = mfloor(n / 256)
|
||||
end
|
||||
bytelist[1] = n % 256
|
||||
for i=1, size do
|
||||
local n = mfloor(data[i])
|
||||
data[i] = n
|
||||
for j=bytes, 2, -1 do
|
||||
bytelist[j] = n % 256
|
||||
n = mfloor(n / 256)
|
||||
end
|
||||
bytelist[1] = n % 256
|
||||
|
||||
file:write(schar(upack(bytelist)))
|
||||
end
|
||||
file:write(schar(upack(bytelist)))
|
||||
end
|
||||
|
||||
file:close()
|
||||
file:close()
|
||||
end
|
||||
|
@ -40,9 +40,9 @@ local function pregenerate(keep_loaded)
|
||||
model:flow()
|
||||
model:erode(time_step)
|
||||
if i < niter then
|
||||
if tectonic_step ~= 0 then
|
||||
nobj_base:get_3d_map_flat({x=0, y=tectonic_step*i, z=0}, ref_dem)
|
||||
end
|
||||
if tectonic_step ~= 0 then
|
||||
nobj_base:get_3d_map_flat({x=0, y=tectonic_step*i, z=0}, ref_dem)
|
||||
end
|
||||
model:isostasy()
|
||||
end
|
||||
end
|
||||
@ -67,12 +67,12 @@ local function pregenerate(keep_loaded)
|
||||
sfile:close()
|
||||
|
||||
if keep_loaded then
|
||||
grid.dem = model.dem
|
||||
grid.lakes = model.lakes
|
||||
grid.dirs = model.dirs
|
||||
grid.rivers = model.rivers
|
||||
grid.offset_x = offset_x
|
||||
grid.offset_y = offset_y
|
||||
grid.dem = model.dem
|
||||
grid.lakes = model.lakes
|
||||
grid.dirs = model.dirs
|
||||
grid.rivers = model.rivers
|
||||
grid.offset_x = offset_x
|
||||
grid.offset_y = offset_y
|
||||
end
|
||||
end
|
||||
|
||||
|
20
settings.lua
20
settings.lua
@ -7,13 +7,13 @@ 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
|
||||
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
|
||||
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
|
||||
end
|
||||
|
||||
mtsettings:set("mapgen_rivers_version", mapgen_rivers.version)
|
||||
@ -72,8 +72,8 @@ mapgen_rivers.settings = {
|
||||
glacier_factor = def_setting('glacier_factor', 'number', 8),
|
||||
elevation_chill = def_setting('elevation_chill', 'number', 0.25),
|
||||
|
||||
grid_x_size = def_setting('grid_x_size', 'number', 1000),
|
||||
grid_z_size = def_setting('grid_z_size', 'number', 1000),
|
||||
grid_x_size = def_setting('grid_x_size', 'number', 1000),
|
||||
grid_z_size = def_setting('grid_z_size', 'number', 1000),
|
||||
evol_params = {
|
||||
K = def_setting('river_erosion_coef', 'number', 0.5),
|
||||
m = def_setting('river_erosion_power', 'number', 0.4),
|
||||
@ -84,7 +84,7 @@ mapgen_rivers.settings = {
|
||||
evol_time = def_setting('evol_time', 'number', 10),
|
||||
evol_time_step = def_setting('evol_time_step', 'number', 1),
|
||||
|
||||
load_all = mtsettings:get_bool('mapgen_rivers_load_all')
|
||||
load_all = mtsettings:get_bool('mapgen_rivers_load_all')
|
||||
}
|
||||
|
||||
local function write_settings()
|
||||
|
Loading…
Reference in New Issue
Block a user