1
0
mirror of git://repo.or.cz/rocks.git synced 2025-01-01 14:00:30 +01:00

Changed api to prepare for mapgen rewrite.

This commit is contained in:
Tomáš Brada 2015-04-16 23:03:50 +02:00
parent aaa6ddeb3f
commit c02b173bf0
3 changed files with 38 additions and 32 deletions

21
ign.lua
View File

@ -3,6 +3,7 @@
--
local ign={
name="ign",
top={
offset = -10, scale = 0,
spread = {x=80, y=80, z=80},
@ -17,6 +18,8 @@ local ign={
debugging=nil
}
rocks.layer_initialize(ign)
-- Basalt Ex/Mafic hard same as diorite, byt limit=0.5
minetest.register_node( "rocks:basalt", {
description = S("Basalt"),
@ -58,10 +61,7 @@ rocks.register_igneous_stratus=reg
-- vein stuff
ign.veins={}
local regv=function(name,param)
rocksl.register_vein(ign.veins,name,param)
end
rocks.register_vein=regv
local regv=rocks.register_vein
rocks.register_vein("default:nyancat",{
wherein={"rocks:granite"},
@ -76,17 +76,4 @@ rocks.register_vein("default:nyancat",{
})
minetest.register_on_generated(function(minp, maxp, seed)
rocksl.layergen(ign,minp,maxp,seed)
rocksl.veingen(ign.veins,minp,maxp,seed)
end)
minetest.register_on_shutdown(function()
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
rocksl.print("[rocks](ign) "..name..": "..total.." nodes placed ("..(total*100)/(ign.stats.totalnodes).." %)")
end
end)
-- ~ Tomas Brod

View File

@ -3,7 +3,7 @@
--
local print2=function(text)
minetest.log("verbose","rocks/gen/ "..text)
minetest.log("info","rocks/gen/ "..text)
end
rocksl.seedseq=0
@ -13,6 +13,13 @@ rocksl.GetNextSeed=function()
return rocksl.seedseq
end
local layers={}
rocks.layer_initialize=function(layer)
layer.stats={ count=0, total=0, node={}, totalnodes=0 }
table.insert(layers,layer)
end
rocksl.register_stratus=function(layer,name,param)
table.insert(layer.localized,{
primary=name,
@ -25,7 +32,9 @@ rocksl.register_stratus=function(layer,name,param)
layer.stats.node[name]=0
end
rocksl.register_vein=function(col,name,param)
local veins={}
rocks.register_vein=function(name,param)
local d={
primary=name,
wherein=param.wherein,
@ -35,7 +44,7 @@ rocksl.register_vein=function(col,name,param)
rarity=param.rarity,
secondary=(param.ores or {}),
}
table.insert(col,d)
table.insert(veins,d)
end
-- TODO: rewrite above function to register normal minetest ore, with
@ -199,4 +208,23 @@ rocksl.veingen=function(veins,minp,maxp,seed)
end
end
minetest.register_on_generated(function(minp, maxp, seed)
for _,layer in pairs(layers) do rocksl.layergen(layer,minp,maxp,seed) end
rocksl.veingen(veins,minp,maxp,seed)
end)
minetest.register_on_shutdown(function()
for _,ign in pairs(layers) do
print("[rocks] Stats for layer "..ign.name)
if (ign.stats.count==0) then
print("[rocks] |- stats not available, no chunks generated")
else
print("[rocks] |- 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] |- "..name..": "..total.." nodes placed ("..(total*100)/(ign.stats.totalnodes).." %)")
end
end
end
end)
-- ~ Tomas Brod

15
sed.lua
View File

@ -3,6 +3,7 @@
--
local sed={
name="sed",
top={
offset = 20, scale = 0,
spread = {x=80, y=80, z=80},
@ -17,6 +18,8 @@ local sed={
debugging=nil
}
rocks.layer_initialize(sed)
-- Mudstone Sed soft Ocean, beach, river, glaciers
minetest.register_node( "rocks:mudstone", {
description = S("Mudstone"),
@ -53,16 +56,4 @@ rocks.register_sedimentary=reg
reg("default:stone_with_coal", { spread=48, height=14, treshold=0.50 })
reg("default:clay",{ spread=48, height=14, treshold=0.50 })
minetest.register_on_generated(function(minp, maxp, seed)
rocksl.layergen(sed,minp,maxp,seed)
end)
minetest.register_on_shutdown(function()
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
rocksl.print("[rocks](sed) "..name..": "..total.." nodes placed ("..(total*100)/(sed.stats.totalnodes).." %)")
end
end)
-- ~ Tomas Brod