From c1cf871d2c43bdb8e1c674acc0cf84b8943af05b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Sat, 4 Apr 2015 00:10:37 +0200 Subject: [PATCH] Renamed mapgen strata register func, added reg for veins, disabled debug. --- ign.lua | 32 +++++++++++++++----------------- mapgen.lua | 21 +++++++++++++++------ sed.lua | 2 +- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/ign.lua b/ign.lua index 9ba1ea8..6b1a218 100644 --- a/ign.lua +++ b/ign.lua @@ -46,9 +46,9 @@ minetest.register_node( "rocks:gabbro", { }) local reg=function(name,param) - rocksl.register_blob(ign,name,param) + rocksl.register_stratus(ign,name,param) end -rocks.register_igneous=reg +rocks.register_igneous_stratus=reg -- rock registration reg("rocks:granite", { spread=40, height=32, treshold=0.06}) @@ -56,24 +56,22 @@ rocks.register_igneous=reg reg("rocks:gabbro", { spread=40, height=32, treshold=0.36}) -- vein stuff -local sample_vein_col={ - { primary="default:nyancat", - wherein="rocks:granite", - miny=-160, maxy=20, - radius={ average=10, amplitude=4, frequency=8 }, - density=1, - rarity=0.025, -- this^3*mapblock_volume veins per mapblock - localized={ - { primary="rocks:pegmatite_diamond", size=3, count=5, - rarity=0.3 -- (this/count) chance of spawning cluster in the vein - } - } - } -} +ign.veins={} + +rocksl.register_vein(ign.veins,"default:nyancat",{ + wherein="rocks:granite", + miny=-160, maxy=20, + radius={ average=10, amplitude=4, frequency=8 }, + density=1, + rarity=0.025, -- this^3*mapblock_volume veins per mapblock + }) + +-- { primary="rocks:pegmatite_diamond", size=3, count=5, +-- rarity=0.3 -- (this/count) chance of spawning cluster in the vein minetest.register_on_generated(function(minp, maxp, seed) rocksl.layergen(ign,minp,maxp,seed) - rocksl.veingen(sample_vein_col,minp,maxp,seed) + rocksl.veingen(ign.veins,minp,maxp,seed) end) minetest.register_on_shutdown(function() diff --git a/mapgen.lua b/mapgen.lua index fff253b..e665add 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -13,7 +13,7 @@ rocksl.GetNextSeed=function() return rocksl.seedseq end -rocksl.register_blob=function(layer,name,param) +rocksl.register_stratus=function(layer,name,param) table.insert(layer.localized,{ primary=name, spread=(param.spread or 20), @@ -25,7 +25,17 @@ rocksl.register_blob=function(layer,name,param) layer.stats.node[name]=0 end -rocksl.register_vein=function(layer,name,param) +rocksl.register_vein=function(col,name,param) + table.insert(col,{ + primary=name, + wherein=param.wherein, + miny=param.miny, maxy=param.maxy, + radius={ average=param.radius.average, amplitude=param.radius.amplitude, frequency=param.radius.frequency }, + density=(param.density or 1), + rarity=param.rarity, + localized={} + }) +end rocksl.layergen=function(layer, minp, maxp, seed) if ( (layer.top.offset+layer.top.scale)>minp.y ) @@ -103,12 +113,11 @@ rocksl.layergen=function(layer, minp, maxp, seed) end end -local ignore_wherein=1 +local ignore_wherein=nil rocksl.veingen=function(veins,minp,maxp,seed) local side_length=(maxp.y-minp.y) local random=PseudoRandom(seed-79) - print("begin veingen") local timebefore=os.clock(); local manipulator, emin, emax = minetest.get_mapgen_object("voxelmanip") local nodes = manipulator:get_data() @@ -130,7 +139,7 @@ rocksl.veingen=function(veins,minp,maxp,seed) iterations_count=iterations_count+(random:next(0,100)/100) local primary_ctx=minetest.get_content_id(vein.primary) local wherein_ctx=minetest.get_content_id(vein.wherein) - print("vein "..vein.primary.." ic="..iterations_count.." p="..primary_ctx.." w="..wherein_ctx) + --print("vein "..vein.primary.." ic="..iterations_count.." p="..primary_ctx.." w="..wherein_ctx) for iteration=1, iterations_count do local x0=minp.x+ random:next(0,side_length) local y0=minp.y+ random:next(0,side_length) @@ -139,7 +148,7 @@ rocksl.veingen=function(veins,minp,maxp,seed) local noise_ix=1 local posi = area:index(x0, y0, z0) if ignore_wherein or (nodes[posi]==wherein_ctx) then - print("vein "..vein.primary.." @ "..x0..","..y0..","..z0.." vrm="..vrm) + --print("vein "..vein.primary.." @ "..x0..","..y0..","..z0.." vrm="..vrm) did_generate=1 for x=-vrm, vrm do for y=-vrm, vrm do diff --git a/sed.lua b/sed.lua index 4f7c8b4..c233570 100644 --- a/sed.lua +++ b/sed.lua @@ -35,7 +35,7 @@ minetest.register_node( "rocks:limestone", { local reg=function(name,param) - rocksl.register_blob(sed,name,param) + rocksl.register_stratus(sed,name,param) end rocks.register_sedimentary=reg