1
0
mirror of git://repo.or.cz/rocks.git synced 2025-01-04 07:10:28 +01:00
rocks/depositgen/init.lua

48 lines
1.1 KiB
Lua
Raw Normal View History

2015-06-30 13:29:11 +02:00
depositgen={}
local l={}
depositgen.l=l
l.print=function(text)
2015-07-02 15:47:17 +02:00
minetest.log("action","[depositgen] "..text)
2015-06-30 13:29:11 +02:00
end
l.print("mod initializing")
local modpath=minetest.get_modpath(minetest.get_current_modname())
l.OnGenerate={}
l.OnInit={}
l.ToResolve={}
local includes={
2015-07-02 15:47:17 +02:00
"pipes" --,"veins"
2015-06-30 13:29:11 +02:00
}
minetest.register_on_generated(function(minp,maxp,seed)
2015-07-02 15:47:17 +02:00
l.print("on generated")
2015-06-30 13:29:11 +02:00
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
local pr=PseudoRandom(seed)
2015-07-02 15:47:17 +02:00
for i=1, #l.OnGenerate do
l.OnGenerate[i](minp,maxp,pr,vm,area)
2015-06-30 13:29:11 +02:00
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")
2015-07-02 15:47:17 +02:00
for index,i in pairs(l.ToResolve) do
i.id=minetest.get_content_id(i.name)
i.name=nil --free some memory
2015-06-30 13:29:11 +02:00
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