mirror of
git://repo.or.cz/rocks.git
synced 2024-11-16 07:20: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)
|
end)
|
||||||
|
|
||||||
minetest.register_on_shutdown(function()
|
minetest.register_on_shutdown(function()
|
||||||
if (ign.stats.count==0) then print("[rocks](ign) stats not available, no chunks generated") return end
|
if (ign.stats.count==0) then rocksl.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)")
|
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
|
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
|
||||||
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
|
-- Load translation library if intllib is installed
|
||||||
|
|
||||||
|
@ -12,6 +12,10 @@ end
|
||||||
rocks={}
|
rocks={}
|
||||||
rocksl={}
|
rocksl={}
|
||||||
|
|
||||||
|
rocksl.print=function(text)
|
||||||
|
print("[rocks] "..text)
|
||||||
|
end
|
||||||
|
|
||||||
local modpath=minetest.get_modpath(minetest.get_current_modname())
|
local modpath=minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
dofile(modpath.."/mapgen.lua")
|
dofile(modpath.."/mapgen.lua")
|
||||||
|
|
14
mapgen.lua
14
mapgen.lua
|
@ -2,10 +2,14 @@
|
||||||
-- layer generator
|
-- layer generator
|
||||||
--
|
--
|
||||||
|
|
||||||
|
local print2=function(text)
|
||||||
|
minetest.log("verbose","rocks/gen/ "..text)
|
||||||
|
end
|
||||||
|
|
||||||
rocksl.seedseq=0
|
rocksl.seedseq=0
|
||||||
rocksl.GetNextSeed=function()
|
rocksl.GetNextSeed=function()
|
||||||
rocksl.seedseq=rocksl.seedseq+20
|
rocksl.seedseq=rocksl.seedseq+20
|
||||||
print("seed "..rocksl.seedseq)
|
print2("seed "..rocksl.seedseq)
|
||||||
return rocksl.seedseq
|
return rocksl.seedseq
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -56,13 +60,13 @@ rocksl.layergen=function(layer, minp, maxp, seed)
|
||||||
end
|
end
|
||||||
local noise2d_ix = 1
|
local noise2d_ix = 1
|
||||||
local noise3d_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 z=minp.z,maxp.z,1 do
|
||||||
for y=minp.y,maxp.y,1 do
|
for y=minp.y,maxp.y,1 do
|
||||||
for x=minp.x,maxp.x,1 do
|
for x=minp.x,maxp.x,1 do
|
||||||
local pos = area:index(x, y, z)
|
local pos = area:index(x, y, z)
|
||||||
if (y>bottom[noise2d_ix])
|
if (y>bottom[noise2d_ix])
|
||||||
and ((nodes[pos]==stone_ctx) or (nodes[pos]==dirt_ctx))
|
and (nodes[pos]~=air_ctx)
|
||||||
then
|
then
|
||||||
layer.stats.totalnodes=layer.stats.totalnodes+1
|
layer.stats.totalnodes=layer.stats.totalnodes+1
|
||||||
if nodes[pos]==stone_ctx then nodes[pos] = layer.primary.ctx end
|
if nodes[pos]==stone_ctx then nodes[pos] = layer.primary.ctx end
|
||||||
|
@ -81,7 +85,7 @@ rocksl.layergen=function(layer, minp, maxp, seed)
|
||||||
end
|
end
|
||||||
noise2d_ix=noise2d_ix+side_length
|
noise2d_ix=noise2d_ix+side_length
|
||||||
end
|
end
|
||||||
print("after loop: "..(os.clock()-timebefore))
|
print2("after loop: "..(os.clock()-timebefore))
|
||||||
manipulator:set_data(nodes)
|
manipulator:set_data(nodes)
|
||||||
--manipulator:calc_lighting()
|
--manipulator:calc_lighting()
|
||||||
--manipulator:update_liquids()
|
--manipulator:update_liquids()
|
||||||
|
@ -89,7 +93,7 @@ rocksl.layergen=function(layer, minp, maxp, seed)
|
||||||
manipulator:set_lighting({day=15,night=15})
|
manipulator:set_lighting({day=15,night=15})
|
||||||
end
|
end
|
||||||
manipulator:write_to_map()
|
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.count=layer.stats.count+1
|
||||||
layer.stats.total=layer.stats.total+(os.clock()-timebefore)
|
layer.stats.total=layer.stats.total+(os.clock()-timebefore)
|
||||||
layer.stats.side=side_length
|
layer.stats.side=side_length
|
||||||
|
|
6
sed.lua
6
sed.lua
|
@ -58,10 +58,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_shutdown(function()
|
minetest.register_on_shutdown(function()
|
||||||
if (sed.stats.count==0) then print("[rocks](sed) stats not available, no chunks generated") return end
|
if (sed.stats.count==0) then rocksl.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)")
|
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
|
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
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user