Code style consistency: use tabs for indentation in all Lua code

This commit is contained in:
Gaël C 2021-07-24 18:55:13 +02:00
parent 95e87f8820
commit 2c5e0ee5af
4 changed files with 60 additions and 60 deletions

View File

@ -1,34 +1,34 @@
local function fix_min_catchment(settings, is_global) 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") local min_catchment = settings:get(prefix.."min_catchment")
if min_catchment then if min_catchment then
min_catchment = tonumber(min_catchment) min_catchment = tonumber(min_catchment)
local blocksize = tonumber(settings:get(prefix.."blocksize") or 15) local blocksize = tonumber(settings:get(prefix.."blocksize") or 15)
settings:set(prefix.."min_catchment", tonumber(min_catchment) * blocksize*blocksize) settings:set(prefix.."min_catchment", tonumber(min_catchment) * blocksize*blocksize)
local max_catchment = settings:get(prefix.."max_catchment") local max_catchment = settings:get(prefix.."max_catchment")
if max_catchment then if max_catchment then
max_catchment = tonumber(max_catchment) max_catchment = tonumber(max_catchment)
local wpower = math.log(2*blocksize)/math.log(max_catchment/min_catchment) local wpower = math.log(2*blocksize)/math.log(max_catchment/min_catchment)
settings:set(prefix.."river_widening_power", wpower) settings:set(prefix.."river_widening_power", wpower)
end end
end end
end end
local function fix_compatibility_minetest(settings) 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 if previous_version == "0.0" then
fix_min_catchment(settings, true) fix_min_catchment(settings, true)
end end
end end
local function fix_compatibility_mapgen_rivers(settings) 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 if previous_version == "0.0" then
fix_min_catchment(settings, false) fix_min_catchment(settings, false)
end end
end end
return fix_compatibility_minetest, fix_compatibility_mapgen_rivers return fix_compatibility_minetest, fix_compatibility_mapgen_rivers

View File

@ -73,28 +73,28 @@ function mapgen_rivers.interactive_loader(filename, bytes, signed, size, convert
end end
function mapgen_rivers.write_map(filename, data, bytes) function mapgen_rivers.write_map(filename, data, bytes)
local size = #data local size = #data
local file = io.open(worldpath .. filename, 'wb') local file = io.open(worldpath .. filename, 'wb')
local mfloor = math.floor local mfloor = math.floor
local schar = string.char local schar = string.char
local upack = unpack local upack = unpack
local bytelist = {} local bytelist = {}
for j=1, bytes do for j=1, bytes do
bytelist[j] = 0 bytelist[j] = 0
end end
for i=1, size do for i=1, size do
local n = mfloor(data[i]) local n = mfloor(data[i])
data[i] = n data[i] = n
for j=bytes, 2, -1 do for j=bytes, 2, -1 do
bytelist[j] = n % 256 bytelist[j] = n % 256
n = mfloor(n / 256) n = mfloor(n / 256)
end end
bytelist[1] = n % 256 bytelist[1] = n % 256
file:write(schar(upack(bytelist))) file:write(schar(upack(bytelist)))
end end
file:close() file:close()
end end

View File

@ -40,9 +40,9 @@ local function pregenerate(keep_loaded)
model:flow() model:flow()
model:erode(time_step) model:erode(time_step)
if i < niter then if i < niter then
if tectonic_step ~= 0 then if tectonic_step ~= 0 then
nobj_base:get_3d_map_flat({x=0, y=tectonic_step*i, z=0}, ref_dem) nobj_base:get_3d_map_flat({x=0, y=tectonic_step*i, z=0}, ref_dem)
end end
model:isostasy() model:isostasy()
end end
end end
@ -67,12 +67,12 @@ local function pregenerate(keep_loaded)
sfile:close() sfile:close()
if keep_loaded then if keep_loaded then
grid.dem = model.dem grid.dem = model.dem
grid.lakes = model.lakes grid.lakes = model.lakes
grid.dirs = model.dirs grid.dirs = model.dirs
grid.rivers = model.rivers grid.rivers = model.rivers
grid.offset_x = offset_x grid.offset_x = offset_x
grid.offset_y = offset_y grid.offset_y = offset_y
end end
end end

View File

@ -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" 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 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") local compat_mt, compat_mgr = dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/compatibility.lua")
if mapgen_rivers.version ~= previous_version_mt then if mapgen_rivers.version ~= previous_version_mt then
compat_mt(mtsettings) compat_mt(mtsettings)
end end
if mapgen_rivers.version ~= previous_version_mgr then if mapgen_rivers.version ~= previous_version_mgr then
compat_mgr(mgrsettings) compat_mgr(mgrsettings)
end end
end end
mtsettings:set("mapgen_rivers_version", mapgen_rivers.version) mtsettings:set("mapgen_rivers_version", mapgen_rivers.version)
@ -72,8 +72,8 @@ mapgen_rivers.settings = {
glacier_factor = def_setting('glacier_factor', 'number', 8), glacier_factor = def_setting('glacier_factor', 'number', 8),
elevation_chill = def_setting('elevation_chill', 'number', 0.25), elevation_chill = def_setting('elevation_chill', 'number', 0.25),
grid_x_size = def_setting('grid_x_size', 'number', 1000), grid_x_size = def_setting('grid_x_size', 'number', 1000),
grid_z_size = def_setting('grid_z_size', 'number', 1000), grid_z_size = def_setting('grid_z_size', 'number', 1000),
evol_params = { evol_params = {
K = def_setting('river_erosion_coef', 'number', 0.5), K = def_setting('river_erosion_coef', 'number', 0.5),
m = def_setting('river_erosion_power', 'number', 0.4), 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 = def_setting('evol_time', 'number', 10),
evol_time_step = def_setting('evol_time_step', 'number', 1), 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() local function write_settings()