mirror of
git://repo.or.cz/rocks.git
synced 2024-11-15 23:10:40 +01:00
Better logging system.
This commit is contained in:
parent
57b51fa10f
commit
f02a668c22
6
ign.lua
6
ign.lua
|
@ -60,10 +60,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
end)
|
||||
|
||||
minetest.register_on_shutdown(function()
|
||||
if (ign.stats.count==0) then print("[rocks](ign) stats not available, no chunks generated") return end
|
||||
print("[rocks](ign) generated total "..ign.stats.count.." chunks in "..ign.stats.total.." seconds ("..(ign.stats.total/ign.stats.count).." seconds per "..ign.stats.side.."^3 chunk)")
|
||||
if (ign.stats.count==0) then rocksl.print("[rocks](ign) stats not available, no chunks generated") return end
|
||||
rocksl.print("[rocks](ign) generated total "..ign.stats.count.." chunks in "..ign.stats.total.." seconds ("..(ign.stats.total/ign.stats.count).." seconds per "..ign.stats.side.."^3 chunk)")
|
||||
for name,total in pairs(ign.stats.node) do
|
||||
print("[rocks](ign) "..name..": "..total.." nodes placed ("..(total*100)/(ign.stats.totalnodes).." %)")
|
||||
rocksl.print("[rocks](ign) "..name..": "..total.." nodes placed ("..(total*100)/(ign.stats.totalnodes).." %)")
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
6
init.lua
6
init.lua
|
@ -1,4 +1,4 @@
|
|||
print("[rocks] mod initializing")
|
||||
minetest.log("info","[rocks] mod initializing")
|
||||
|
||||
-- Load translation library if intllib is installed
|
||||
|
||||
|
@ -12,6 +12,10 @@ end
|
|||
rocks={}
|
||||
rocksl={}
|
||||
|
||||
rocksl.print=function(text)
|
||||
print("[rocks] "..text)
|
||||
end
|
||||
|
||||
local modpath=minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
dofile(modpath.."/mapgen.lua")
|
||||
|
|
14
mapgen.lua
14
mapgen.lua
|
@ -2,10 +2,14 @@
|
|||
-- layer generator
|
||||
--
|
||||
|
||||
local print2=function(text)
|
||||
minetest.log("verbose","rocks/gen/ "..text)
|
||||
end
|
||||
|
||||
rocksl.seedseq=0
|
||||
rocksl.GetNextSeed=function()
|
||||
rocksl.seedseq=rocksl.seedseq+20
|
||||
print("seed "..rocksl.seedseq)
|
||||
print2("seed "..rocksl.seedseq)
|
||||
return rocksl.seedseq
|
||||
end
|
||||
|
||||
|
@ -56,13 +60,13 @@ rocksl.layergen=function(layer, minp, maxp, seed)
|
|||
end
|
||||
local noise2d_ix = 1
|
||||
local noise3d_ix = 1
|
||||
print("after noise: "..(os.clock()-timebefore))
|
||||
print2("after noise: "..(os.clock()-timebefore))
|
||||
for z=minp.z,maxp.z,1 do
|
||||
for y=minp.y,maxp.y,1 do
|
||||
for x=minp.x,maxp.x,1 do
|
||||
local pos = area:index(x, y, z)
|
||||
if (y>bottom[noise2d_ix])
|
||||
and ((nodes[pos]==stone_ctx) or (nodes[pos]==dirt_ctx))
|
||||
and (nodes[pos]~=air_ctx)
|
||||
then
|
||||
layer.stats.totalnodes=layer.stats.totalnodes+1
|
||||
if nodes[pos]==stone_ctx then nodes[pos] = layer.primary.ctx end
|
||||
|
@ -81,7 +85,7 @@ rocksl.layergen=function(layer, minp, maxp, seed)
|
|||
end
|
||||
noise2d_ix=noise2d_ix+side_length
|
||||
end
|
||||
print("after loop: "..(os.clock()-timebefore))
|
||||
print2("after loop: "..(os.clock()-timebefore))
|
||||
manipulator:set_data(nodes)
|
||||
--manipulator:calc_lighting()
|
||||
--manipulator:update_liquids()
|
||||
|
@ -89,7 +93,7 @@ rocksl.layergen=function(layer, minp, maxp, seed)
|
|||
manipulator:set_lighting({day=15,night=15})
|
||||
end
|
||||
manipulator:write_to_map()
|
||||
print("after commit: "..(os.clock()-timebefore))
|
||||
print2("after commit: "..(os.clock()-timebefore))
|
||||
layer.stats.count=layer.stats.count+1
|
||||
layer.stats.total=layer.stats.total+(os.clock()-timebefore)
|
||||
layer.stats.side=side_length
|
||||
|
|
6
sed.lua
6
sed.lua
|
@ -58,10 +58,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
end)
|
||||
|
||||
minetest.register_on_shutdown(function()
|
||||
if (sed.stats.count==0) then print("[rocks](sed) stats not available, no chunks generated") return end
|
||||
print("[rocks](sed) generated total "..sed.stats.count.." chunks in "..sed.stats.total.." seconds ("..(sed.stats.total/sed.stats.count).." seconds per "..sed.stats.side.."^3 chunk)")
|
||||
if (sed.stats.count==0) then rocksl.print("[rocks](sed) stats not available, no chunks generated") return end
|
||||
rocksl.print("[rocks](sed) generated total "..sed.stats.count.." chunks in "..sed.stats.total.." seconds ("..(sed.stats.total/sed.stats.count).." seconds per "..sed.stats.side.."^3 chunk)")
|
||||
for name,total in pairs(sed.stats.node) do
|
||||
print("[rocks](sed) "..name..": "..total.." nodes placed ("..(total*100)/(sed.stats.totalnodes).." %)")
|
||||
rocksl.print("[rocks](sed) "..name..": "..total.." nodes placed ("..(total*100)/(sed.stats.totalnodes).." %)")
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user