mirror of
git://repo.or.cz/rocks.git
synced 2025-01-01 14:00:30 +01:00
47 lines
1.0 KiB
Lua
47 lines
1.0 KiB
Lua
depositgen={}
|
|
local l={}
|
|
depositgen.l=l
|
|
|
|
l.print=function(text)
|
|
minetest.log("info","[depositgen] "..text)
|
|
end
|
|
|
|
l.print("mod initializing")
|
|
|
|
local modpath=minetest.get_modpath(minetest.get_current_modname())
|
|
|
|
l.OnGenerate={}
|
|
l.OnInit={}
|
|
l.ToResolve={}
|
|
|
|
local includes={
|
|
"pipes","veins"
|
|
}
|
|
|
|
minetest.register_on_generated(function(minp,maxp,seed)
|
|
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
|
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
|
local pr=PseudoRandom(seed)
|
|
for i=0, #l.OnGenerate do
|
|
l.OnGenerate[i](minp,maxp,seed,vm,area)
|
|
end
|
|
vm:write_to_map()
|
|
end)
|
|
|
|
minetest.register_on_mapgen_init(function(mapgen_params)
|
|
-- todo: disable caves and ores
|
|
-- todo: sort layers
|
|
--Resolve all mapgen nodes to content ids
|
|
l.print("Resolving node names")
|
|
for _,i in pairs(l.ToResolve) do
|
|
i.id=minetest.get_content_id(i.node)
|
|
i.node=nil --free some memory
|
|
end
|
|
l.print("running mapgen initialization tasks")
|
|
for _,i in pairs(l.OnInit) do
|
|
i(mapgen_params)
|
|
end
|
|
end)
|
|
|
|
for _,s in pairs(includes) do dofile(modpath.."/"..s..".lua") end
|