From 9b9419f2ebc953ef62c07b5e40be4be9ca0e469b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Tue, 30 Jun 2015 13:29:11 +0200 Subject: [PATCH] New oregen init. --- depositgen/init.lua | 46 +++++++++++++++++++++++++++++++++++++++++++++ rocks/init.lua | 42 ----------------------------------------- 2 files changed, 46 insertions(+), 42 deletions(-) create mode 100644 depositgen/init.lua delete mode 100644 rocks/init.lua diff --git a/depositgen/init.lua b/depositgen/init.lua new file mode 100644 index 0000000..c38aeeb --- /dev/null +++ b/depositgen/init.lua @@ -0,0 +1,46 @@ +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","layers" +} + +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 diff --git a/rocks/init.lua b/rocks/init.lua deleted file mode 100644 index 657da20..0000000 --- a/rocks/init.lua +++ /dev/null @@ -1,42 +0,0 @@ -minetest.log("info","[rocks] mod initializing") - --- Load translation library if intllib is installed - -if (minetest.get_modpath("intllib")) then - dofile(minetest.get_modpath("intllib").."/intllib.lua") - S = intllib.Getter(minetest.get_current_modname()) - else - S = function ( s ) return s end -end - -rocks={} -rocksl={} - -rocksl.print=function(text) - minetest.log("info","/rocks "..text) -end - -rocksl.seedprng=PseudoRandom(763) -rocksl.GetNextSeed=function() - return rocksl.seedprng:next() -end - -minetest.clear_registered_ores() - -local modpath=minetest.get_modpath(minetest.get_current_modname()) - ---dofile(modpath.."/pipes.lua") ---dofile(modpath.."/veins.lua") -dofile(modpath.."/layers.lua") - -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) - rocksl.genlayers(minp,maxp,seed,vm,area) - vm:write_to_map() -end) - -minetest.register_on_mapgen_init(function(mapgen_params) - -- todo: disable caves and ores -end)