From 12f7c99e9f19df4e77c061c6bb967f8fe2947c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Wed, 1 Apr 2015 21:46:30 +0200 Subject: [PATCH] Sedimentary layer rewrite. --- init.lua | 33 +++---------- register.lua | 61 ------------------------ sed.lua | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+), 87 deletions(-) delete mode 100644 register.lua create mode 100644 sed.lua diff --git a/init.lua b/init.lua index 237f45b..a81ea09 100644 --- a/init.lua +++ b/init.lua @@ -7,36 +7,17 @@ if (minetest.get_modpath("intllib")) then S = function ( s ) return s end end +rocks={} + local modpath=minetest.get_modpath(minetest.get_current_modname()) -dofile(modpath.."/register.lua") +print("[rocks] begin") -rocks.noiseparams_layers = { - offset = 0, - scale = 1, - spread = {x=80, y=80, z=80}, - octaves = 2, - persist = 0.7 -} - -dofile(modpath.."/mapgen.lua") ---dofile(modpath.."/testing.lua") - -print("[rocks] core loaded.") - -dofile(modpath.."/geologicaLayers.lua") -dofile(modpath.."/geologicaStrata.lua") -dofile(modpath.."/geologicaVeins.lua") +dofile(modpath.."/sed.lua") minetest.register_on_mapgen_init(function(mapgen_params) - - for i,d in pairs(rocks.layers_name) do table.insert(rocks.layers,d) end - table.sort(rocks.layers,function(a,b) - return a.heightClaystone Weak Localized continental, folded, oceanic +--Conglomerate Weak Localized continental, folded +-->Limestone Medium Localized continental, folded; primary oceanic, hills +-->Coal - Large beds, twice as common in swamps + --reg("rocks:breccia", { spread=35, height=30, treshold=0.85 }) + reg("default:clay",{ spread=40, height=30, treshold=0.70 }) + --reg("rocks:conglomerate", { spread=35, height=30, treshold=0.85 }) + reg("rocks:limestone", { spread=40, height=30, treshold=0.80 }) + reg("default:stone_with_coal", { spread=10, height=6, treshold=0.70 }) + +minetest.register_on_generated(function(minp, maxp, seed) + if ( (sed.top.offset+sed.top.scale)>minp.y ) + and ( (sed.bot.offset-sed.bot.scale)bottom[noise2d_ix]) + and ((nodes[pos]==stone_ctx) or (nodes[pos]==dirt_ctx)) + then + nodes[pos] = sed.primary.ctx + for k,loc in pairs(localized) do + if (loc.noise[noise3d_ix]>loc.treshold) then + nodes[pos]=loc.ctx + break + end + end + end + noise2d_ix=noise2d_ix+1 + noise3d_ix=noise3d_ix+1 + end + noise2d_ix = noise2d_ix-side_length + end + end + manipulator:set_data(nodes) + --manipulator:calc_lighting() + manipulator:set_lighting({day=15,night=15}) + --manipulator:update_liquids() + manipulator:write_to_map() + print("[rocks] sedimentary gen2 "..os.clock()-timebefore) + sed.stats.count=sed.stats.count+1 + sed.stats.total=sed.stats.total+(os.clock()-timebefore) + end +end) + +minetest.register_on_shutdown(function() + print("[rocks](sed) on_shutdown: generated total "..sed.stats.count.." chunks in "..sed.stats.total.." seconds ("..(sed.stats.total/sed.stats.count).." seconds per chunk)") +end) + +-- ~ Tomas Brod \ No newline at end of file