mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2024-11-13 06:10:21 +01:00
Use builtin logging system and appropriate loglevels
This commit is contained in:
parent
c3a798933f
commit
417ce1bcbc
12
init.lua
12
init.lua
|
@ -6,7 +6,7 @@ mapgen_rivers.world_data_path = minetest.get_worldpath() .. '/river_data/'
|
|||
|
||||
if minetest.get_mapgen_setting("mg_name") ~= "singlenode" then
|
||||
minetest.set_mapgen_setting("mg_name", "singlenode", true)
|
||||
print("[mapgen_rivers] Mapgen set to singlenode")
|
||||
minetest.log("warning", "[mapgen_rivers] Mapgen set to singlenode")
|
||||
end
|
||||
|
||||
dofile(modpath .. 'settings.lua')
|
||||
|
@ -51,7 +51,7 @@ local sumtime2 = 0
|
|||
local ngen = 0
|
||||
|
||||
local function generate(minp, maxp, seed)
|
||||
print(("[mapgen_rivers] Generating from %s to %s"):format(minetest.pos_to_string(minp), minetest.pos_to_string(maxp)))
|
||||
minetest.log("info", ("[mapgen_rivers] Generating from %s to %s"):format(minetest.pos_to_string(minp), minetest.pos_to_string(maxp)))
|
||||
|
||||
local chulens = {
|
||||
x = maxp.x-minp.x+1,
|
||||
|
@ -141,8 +141,8 @@ local function generate(minp, maxp, seed)
|
|||
sumtime = sumtime + t
|
||||
sumtime2 = sumtime2 + t*t
|
||||
|
||||
print("[mapgen_rivers] Skipping empty chunk (fully above ground level)")
|
||||
print(("[mapgen_rivers] Done in %5.3f s"):format(t))
|
||||
minetest.log("verbose", "[mapgen_rivers] Skipping empty chunk (fully above ground level)")
|
||||
minetest.log("verbose", ("[mapgen_rivers] Done in %5.3f s"):format(t))
|
||||
return
|
||||
end
|
||||
end
|
||||
|
@ -264,12 +264,12 @@ local function generate(minp, maxp, seed)
|
|||
ngen = ngen + 1
|
||||
sumtime = sumtime + t
|
||||
sumtime2 = sumtime2 + t*t
|
||||
print(("[mapgen_rivers] Done in %5.3f s"):format(t))
|
||||
minetest.log("verbose", ("[mapgen_rivers] Done in %5.3f s"):format(t))
|
||||
end
|
||||
|
||||
minetest.register_on_generated(generate)
|
||||
minetest.register_on_shutdown(function()
|
||||
local avg = sumtime / ngen
|
||||
local std = math.sqrt(sumtime2/ngen - avg*avg)
|
||||
print(("[mapgen_rivers] Mapgen statistics:\n- Mapgen calls: %4d\n- Mean time: %5.3f s\n- Standard deviation: %5.3f s"):format(ngen, avg, std))
|
||||
minetest.log("action", ("[mapgen_rivers] Mapgen statistics:\n- Mapgen calls: %4d\n- Mean time: %5.3f s\n- Standard deviation: %5.3f s"):format(ngen, avg, std))
|
||||
end)
|
||||
|
|
|
@ -73,7 +73,7 @@ for name, np in pairs(mapgen_rivers.noise_params) do
|
|||
if lac > 1 then
|
||||
local omax = math.floor(math.log(math.min(np.spread.x, np.spread.y, np.spread.z)) / math.log(lac))+1
|
||||
if np.octaves > omax then
|
||||
print("[mapgen_rivers] Noise " .. name .. ": 'octaves' reduced to " .. omax)
|
||||
minetest.log("warning", "[mapgen_rivers] Noise " .. name .. ": 'octaves' reduced to " .. omax)
|
||||
np.octaves = omax
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ if first_mapgen then
|
|||
-- Generate a map!!
|
||||
local pregenerate = dofile(mapgen_rivers.modpath .. '/pregenerate.lua')
|
||||
minetest.register_on_mods_loaded(function()
|
||||
print('[mapgen_rivers] Generating grid')
|
||||
minetest.log("action", '[mapgen_rivers] Generating grid, this may take a while...')
|
||||
pregenerate(load_all)
|
||||
|
||||
if load_all then
|
||||
|
@ -58,9 +58,9 @@ if not (first_mapgen and load_all) then
|
|||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
if load_all then
|
||||
print('[mapgen_rivers] Loading full grid')
|
||||
minetest.log("action", '[mapgen_rivers] Loading full grid')
|
||||
else
|
||||
print('[mapgen_rivers] Loading grid as interactive loaders')
|
||||
minetest.log("action", '[mapgen_rivers] Loading grid as interactive loaders')
|
||||
end
|
||||
local grid = mapgen_rivers.grid
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ local function pregenerate(keep_loaded)
|
|||
local tectonic_step = tectonic_speed * time_step
|
||||
collectgarbage()
|
||||
for i=1, niter do
|
||||
print("[mapgen_rivers] Iteration " .. i .. " of " .. niter)
|
||||
minetest.log("info", "[mapgen_rivers] Iteration " .. i .. " of " .. niter)
|
||||
|
||||
model:diffuse(time_step)
|
||||
model:flow()
|
||||
|
|
Loading…
Reference in New Issue
Block a user