From f5c693c1de2def44851ec397addd1958c72e96d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Sun, 8 Feb 2015 21:36:34 +0100 Subject: [PATCH 01/18] Forgot to add testing file. --- testing.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 testing.lua diff --git a/testing.lua b/testing.lua new file mode 100644 index 0000000..8a65aac --- /dev/null +++ b/testing.lua @@ -0,0 +1,12 @@ +rocks.register_layer("testl", { gain=20, height=-55, limit=2, seed=1 }, "default:wood") + +rocks.register_vein("clay",{ + spread = {x=30, y=10, z=30}, + treshold=0.2, -- clay should be plenty + seed = 9, + hmin=-8, hmax=nil, + layers={ "mudstone" }, +}) + +rocks.register_ore( "clay", "default:clay", {treshold=0, chance=85 } ) +rocks.register_ore( "clay", "default:torch", {treshold=0, chance=15 } ) From 6d5bfbb42d8c2f13241f695b66b7740e1d950020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Sun, 8 Feb 2015 21:44:04 +0100 Subject: [PATCH 02/18] Added sorting on mapgen init. Split geologica to submodules. --- geologica.lua => geologicaLayers.lua | 2 ++ geologica_nv.lua => geologicaStrata.lua | 2 +- geologicaVeins.lua | 11 +++++++++++ init.lua | 25 +++++++++++++------------ 4 files changed, 27 insertions(+), 13 deletions(-) rename geologica.lua => geologicaLayers.lua (99%) rename geologica_nv.lua => geologicaStrata.lua (96%) create mode 100644 geologicaVeins.lua diff --git a/geologica.lua b/geologicaLayers.lua similarity index 99% rename from geologica.lua rename to geologicaLayers.lua index d627623..dab4f9b 100644 --- a/geologica.lua +++ b/geologicaLayers.lua @@ -122,3 +122,5 @@ minetest.register_node( "rocks:andesite", { is_ground_content = true, sounds = default.node_sound_stone_defaults(), }) rocks.register_layer( "andesite",{ gain=8, height=10, limit=2, seed=4 }, "rocks:andesite") + +print("[rocks/geologicaLayers] loaded.") diff --git a/geologica_nv.lua b/geologicaStrata.lua similarity index 96% rename from geologica_nv.lua rename to geologicaStrata.lua index 6238147..67e61ce 100644 --- a/geologica_nv.lua +++ b/geologicaStrata.lua @@ -34,4 +34,4 @@ rocks.register_vein("limestone",{ -- Dolomite Sed med in Rhyolite, Andesite in mountains -- Quartzite MM/contact vhard sandstone - +print("[rocks/geologicaStrata] loaded.") \ No newline at end of file diff --git a/geologicaVeins.lua b/geologicaVeins.lua new file mode 100644 index 0000000..0f77cc0 --- /dev/null +++ b/geologicaVeins.lua @@ -0,0 +1,11 @@ +local CcHard=3 +local CcStrong=3 +local CcMed=3 +local CcSoft=3 + +-- +-- Veins +-- + + +print("[rocks/geologicaVeins] loaded.") diff --git a/init.lua b/init.lua index 2e9477e..c84c4b4 100644 --- a/init.lua +++ b/init.lua @@ -21,18 +21,19 @@ rocks.noiseparams_layers = { dofile(modpath.."/mapgen.lua") --dofile(modpath.."/testing.lua") -dofile(modpath.."/geologica.lua") -dofile(modpath.."/geologica_nv.lua") -print("[rocks] sorting layers") +print("[rocks] core loaded.") + +dofile(modpath.."/geologicaLayers.lua") +dofile(modpath.."/geologicaStrata.lua") +dofile(modpath.."/geologicaVeins.lua") + +minetest.register_on_mapgen_init(function(mapgen_params) + print("[rocks] sorting layers ("..#rocks.layers_name..")") + + for i,d in pairs(rocks.layers_name) do table.insert(rocks.layers,d) end + table.sort(rocks.layers,function(a,b) + return a.height Date: Sun, 8 Feb 2015 21:49:40 +0100 Subject: [PATCH 03/18] Fix. --- init.lua | 5 ++++- mapgen.lua | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index c84c4b4..237f45b 100644 --- a/init.lua +++ b/init.lua @@ -29,11 +29,14 @@ dofile(modpath.."/geologicaStrata.lua") dofile(modpath.."/geologicaVeins.lua") minetest.register_on_mapgen_init(function(mapgen_params) - print("[rocks] sorting layers ("..#rocks.layers_name..")") for i,d in pairs(rocks.layers_name) do table.insert(rocks.layers,d) end table.sort(rocks.layers,function(a,b) return a.height"..ld.name.." top="..ld.height) for vn,vd in pairs(ld.veins) do From f0d193fcfdcbc77d3f4c400ec4ee377250aaba14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Tue, 10 Feb 2015 17:00:04 +0100 Subject: [PATCH 04/18] Add limestne and dolomite. --- geologicaLayers.lua | 24 ++++++++++++------------ geologicaStrata.lua | 41 ++++++++++++++++++++++++++++++----------- geologicaVeins.lua | 4 ++++ mapgen.lua | 1 + register.lua | 4 ++-- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/geologicaLayers.lua b/geologicaLayers.lua index dab4f9b..c414b19 100644 --- a/geologicaLayers.lua +++ b/geologicaLayers.lua @@ -14,7 +14,7 @@ minetest.register_node( "rocks:granite", { is_ground_content = true, sounds = default.node_sound_stone_defaults(), groups = {cracky=CcStrong, stone=1}, }) -rocks.register_layer( "granite",{ gain=20, height=-55, limit=2, seed=1 }, "rocks:granite") +rocks.register_layer( "granite",{ gain=20, height=-22, limit=2, seed=1 }, "rocks:granite") -- Diorite In/Inter vhard Below granite minetest.register_node( "rocks:diorite", { @@ -23,7 +23,7 @@ minetest.register_node( "rocks:diorite", { groups = {cracky=CcHard, stone=1}, is_ground_content = true, sounds = default.node_sound_stone_defaults(), }) -rocks.register_layer( "diorite",{ gain=20, height=-80, limit=2, seed=2 }, "rocks:diorite") +rocks.register_layer( "diorite",{ gain=20, height=-55, limit=2, seed=2 }, "rocks:diorite") -- Basalt Ex/Mafic hard same as diorite, byt limit=0.5 minetest.register_node( "rocks:basalt", { @@ -32,7 +32,7 @@ minetest.register_node( "rocks:basalt", { groups = {cracky=CcStrong, stone=1}, is_ground_content = true, sounds = default.node_sound_stone_defaults(), }) -rocks.register_layer( "basalt",{ gain=20, height=-75, limit=-0.7, seed=2 }, "rocks:basalt") +rocks.register_layer( "basalt",{ gain=20, height=-60, limit=-0.7, seed=2 }, "rocks:basalt") -- Gabbro In/Mafic vhard Below basalt/diorite (mtns, ocean) minetest.register_node( "rocks:gabbro", { @@ -41,7 +41,7 @@ minetest.register_node( "rocks:gabbro", { groups = {cracky=CcHard, stone=1}, is_ground_content = true, sounds = default.node_sound_stone_defaults(), }) -rocks.register_layer( "gabbro",{ gain=20, height=-120, limit=2, seed=3 }, "rocks:gabbro") +rocks.register_layer( "gabbro",{ gain=20, height=-70, limit=2, seed=3 }, "rocks:gabbro") -- Peridotite In/UMafic vhard Rarely under gabbro minetest.register_node( "rocks:peridotite", { @@ -50,7 +50,7 @@ minetest.register_node( "rocks:peridotite", { groups = {cracky=CcStrong, stone=1}, is_ground_content = true, sounds = default.node_sound_stone_defaults(), }) -rocks.register_layer( "peridotite",{ gain=20, height=-130, limit=-0.8, seed=4 }, "rocks:peridotite") +rocks.register_layer( "peridotite",{ gain=20, height=-120, limit=-0.8, seed=4 }, "rocks:peridotite") -- Komatiite Ex/UMafic - Too deep minetest.register_node( "rocks:komatiite", { @@ -59,7 +59,7 @@ minetest.register_node( "rocks:komatiite", { groups = {cracky=CcHard, stone=1}, is_ground_content = true, sounds = default.node_sound_stone_defaults(), }) -rocks.register_layer( "komatiite",{ gain=20, height=-200, limit=2, seed=5 }, "rocks:komatiite") +rocks.register_layer( "komatiite",{ gain=20, height=-130, limit=2, seed=5 }, "rocks:komatiite") -- -- top sedimentary rocks @@ -72,7 +72,7 @@ minetest.register_node( "rocks:mudstone", { groups = {cracky=CcSoft, stone=1}, is_ground_content = true, sounds = default.node_sound_stone_defaults(), }) -rocks.register_layer( "mudstone",{ gain=10, height=-13, limit=2, seed=4 }, "rocks:mudstone") +rocks.register_layer( "mudstone",{ gain=10, height=10, limit=2, seed=4 }, "rocks:mudstone") -- Slate MM/barro med Under mud/clay/siltstone minetest.register_node( "rocks:slate", { @@ -81,7 +81,7 @@ minetest.register_node( "rocks:slate", { groups = {cracky=CcMed, stone=1}, is_ground_content = true, sounds = default.node_sound_stone_defaults(), }) -rocks.register_layer( "slate",{ gain=10, height=-15, limit=2, seed=5 }, "rocks:slate") +-- rocks.register_layer( "slate",{ gain=10, height=-7, limit=2, seed=5 }, "rocks:slate") -- Schist MM/barro med Under slate, sometimes igneous minetest.register_node( "rocks:schist", { @@ -90,7 +90,7 @@ minetest.register_node( "rocks:schist", { groups = {cracky=CcMed, stone=1}, is_ground_content = true, sounds = default.node_sound_stone_defaults(), }) -rocks.register_layer( "schist",{ gain=10, height=-18, limit=2, seed=5 }, "rocks:schist") +rocks.register_layer( "schist",{ gain=10, height=-15, limit=2, seed=5 }, "rocks:schist") -- Gneiss MM/barro hard Under schist, sometimes igneous minetest.register_node( "rocks:gneiss", { @@ -99,7 +99,7 @@ minetest.register_node( "rocks:gneiss", { groups = {cracky=CcStrong, stone=1}, is_ground_content = true, sounds = default.node_sound_stone_defaults(), }) -rocks.register_layer( "gneiss",{ gain=10, height=-21, limit=2, seed=6 }, "rocks:gneiss") +rocks.register_layer( "gneiss",{ gain=10, height=-19, limit=2, seed=6 }, "rocks:gneiss") -- -- peak rocks @@ -112,7 +112,7 @@ minetest.register_node( "rocks:rhyolite", { groups = {cracky=CcHard, stone=1}, is_ground_content = true, sounds = default.node_sound_stone_defaults(), }) -rocks.register_layer( "rhyolite",{ gain=8, height=22, limit=2, seed=4 }, "rocks:rhyolite") +rocks.register_layer( "rhyolite",{ gain=8, height=80, limit=2, seed=4 }, "rocks:rhyolite") -- Andesite Ex/Inter hard Mountains, below rhyolite minetest.register_node( "rocks:andesite", { @@ -121,6 +121,6 @@ minetest.register_node( "rocks:andesite", { groups = {cracky=CcHard, stone=1}, is_ground_content = true, sounds = default.node_sound_stone_defaults(), }) -rocks.register_layer( "andesite",{ gain=8, height=10, limit=2, seed=4 }, "rocks:andesite") +rocks.register_layer( "andesite",{ gain=8, height=22, limit=2, seed=4 }, "rocks:andesite") print("[rocks/geologicaLayers] loaded.") diff --git a/geologicaStrata.lua b/geologicaStrata.lua index 67e61ce..083a4c0 100644 --- a/geologicaStrata.lua +++ b/geologicaStrata.lua @@ -12,26 +12,45 @@ rocks.register_vein("clay",{ spread = {x=30, y=10, z=30}, treshold=0.2, -- clay should be plenty seed = 9, - hmin=-8, hmax=nil, layers={ "mudstone" }, }) rocks.register_ore( "clay", "default:clay", {treshold=0, chance=85 } ) -rocks.register_ore( "clay", "default:torch", {treshold=0, chance=15 } ) -- Breccia Mixture soft in mudstone -- Conglomerate Sed soft in mudstone --- Skarn MM/contact med in mudstone in mountains --- Hornfels MM/contact vhard in mudstone in mountains --- Marble MM/contact hard in mudstone in mountains + -- Limestone Sed med in Rhyolite, Andesite in mountains -rocks.register_vein("limestone",{ - spread = {x=10, y=10, z=10}, - treshold=0.75, - seed = 10, - hmin=nil, hmax=nil, - layers={ "mudstone" }, +minetest.register_node( "rocks:limestone", { + description = S("Limestone"), + tiles = { "rocks_Limestone.png" }, + is_ground_content = true, sounds = default.node_sound_stone_defaults(), + groups = {cracky=CcMed, stone=1}, }) +rocks.register_vein("limestone",{ + spread = {x=60, y=60, z=60}, + treshold=0.4, + seed = 10, + layers={ "rhyolite", "andesite" }, +}) +rocks.register_ore( "limestone", "rocks:limestone", {treshold=0, chance=100} ) +rocks.register_ore( "limestone", "default:torch", {treshold=0, chance=15 } ) + -- Dolomite Sed med in Rhyolite, Andesite in mountains +minetest.register_node( "rocks:dolomite", { + description = S("Dolomite"), + tiles = { "rocks_Dolomite.png" }, + is_ground_content = true, sounds = default.node_sound_stone_defaults(), + groups = {cracky=CcMed, stone=1}, +}) +rocks.register_vein("dolomite",{ + spread = {x=60, y=60, z=60}, + treshold=0.4, + seed = 11, + layers={ "rhyolite", "andesite" }, +}) +rocks.register_ore( "dolomite", "rocks:dolomite", {treshold=0, chance=100} ) +rocks.register_ore( "dolomite", "default:torch", {treshold=0, chance=15 } ) + -- Quartzite MM/contact vhard sandstone print("[rocks/geologicaStrata] loaded.") \ No newline at end of file diff --git a/geologicaVeins.lua b/geologicaVeins.lua index 0f77cc0..13ddb52 100644 --- a/geologicaVeins.lua +++ b/geologicaVeins.lua @@ -7,5 +7,9 @@ local CcSoft=3 -- Veins -- +-- Skarn MM/contact med in rhyo/ande in mountains +-- Hornfels MM/contact vhard in skarn +-- Marble MM/contact hard in skarn +-- Limestone Sed med in skarn print("[rocks/geologicaVeins] loaded.") diff --git a/mapgen.lua b/mapgen.lua index 601150e..baab9ba 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -87,6 +87,7 @@ minetest.register_on_generated(function(minp, maxp, seed) if vd.nmap[noise3d_ix]>vd.treshold then vein=vd --rock not changed + break end end end diff --git a/register.lua b/register.lua index b6b5860..59a8217 100644 --- a/register.lua +++ b/register.lua @@ -19,14 +19,14 @@ rocks.register_layer=function(name,params,rock) gain=params.gain, height=params.height, maxheight=maxheight, - limit=((params.limit or 2)*params.gain)+params.height, + limit=(params.limit*params.gain)+params.height, seed=params.seed or 0, rock={ node=rock }, veins={}, name=name } rocks.layers_name[name]= ld - print("[rocks] layer "..ld.name) + print("[rocks] layer "..ld.name.."height="..ld.height.." limit="..ld.limit) end rocks.register_vein=function(name,params) From 4ce4bdfa88096554bee92b783ad140131c7278ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Tue, 10 Feb 2015 17:00:29 +0100 Subject: [PATCH 05/18] Lime/Dolo textures. --- textures/rocks_Dolomite.png | Bin 0 -> 772 bytes textures/rocks_Limestone.png | Bin 0 -> 794 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 textures/rocks_Dolomite.png create mode 100644 textures/rocks_Limestone.png diff --git a/textures/rocks_Dolomite.png b/textures/rocks_Dolomite.png new file mode 100644 index 0000000000000000000000000000000000000000..a590cb0aac8e6f06c8751b8d81f77967f2b4000e GIT binary patch literal 772 zcmV+f1N;1mP)WFTUBAVFhebyII@_;ojqoHS5!Q`G~VCesJ)PDvj|-UAdxiltU%Uk~K@ z_n-c;z4$p#7*WpJ@Mv?k2LN0}p zPxkGJbxKY<&UONo+%uzhl#l~ddV)zDt*}g;hrME}u&0RKIf&;$%8gv% zx{Tyfpmi?GM6*C>ct)H_Xv%!8k=uR54IWLYaRdOv;v8BHsS3u=tTB>$XQN`gW4=G= z)^LB^kqY@t*c3C?86KA_;RuKdS3faMGd+0*BfP&hoOWDpv;?`W%)=EsDApU8-GH>h zGAKWFTUBAVFhebyII1P|3BgWn1buYsuHY{_G__af87c zXnE(gcZTzC^b~onH%@PFSR!$IG7JOv^-igVY4)fXP+P$SYF%j!=6NJO{{=I$%mdOJ zwHAyu)RH)aKy97cI!3L-4kvI6^iDKi$ZcfL%9a|bD6tf7>rTf~apY#mxzk!lQ=h;H zajUrTcWm9ctrn+eS`)@Y!1TiBUw`4T-mu1?KG0rwq<^3y%6(lq9?w8V#q;xJ!DuHI zg$})SKp4Hph>%;w7$|(g^qQELnSHyH;!YR1-fwJ4F@Wirn0HET^wL2DrxrJz@P0sh zd!lwiy+_S}QN!i)8#E!6j#J^_7DNoOLaUin6EPLSG@#4miK!q6HLp-0#|MZIi)CXZ z=R_0FDJ{Enj)qXW5Q{pJg(&0s5vu^jg||}IXXMvuRqYge>`w*BFuqT1kn@J7j|?! zV+9I>YpiJ_wwcKdynpOiGa&YW{&e|++6_592+PboAK7!JRN?;dWC;PO4-WRo=r6<) zIZl;YGU{fG_Y Date: Tue, 10 Feb 2015 17:35:48 +0100 Subject: [PATCH 06/18] Added and tuned coal gen. --- geologicaStrata.lua | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/geologicaStrata.lua b/geologicaStrata.lua index 083a4c0..b9abeef 100644 --- a/geologicaStrata.lua +++ b/geologicaStrata.lua @@ -4,13 +4,13 @@ local CcMed=3 local CcSoft=3 -- --- nonvein vein +-- Sedimentary -- -- Claystone Sed soft in mudstone rocks.register_vein("clay",{ spread = {x=30, y=10, z=30}, - treshold=0.2, -- clay should be plenty + treshold=0.26, -- clay should be plenty seed = 9, layers={ "mudstone" }, }) @@ -19,6 +19,27 @@ rocks.register_ore( "clay", "default:clay", {treshold=0, chance=85 } ) -- Breccia Mixture soft in mudstone -- Conglomerate Sed soft in mudstone +-- Coal Ocean, inland 2x swamp +rocks.register_vein("coal",{ + spread = {x=20, y=10, z=20}, + treshold=0.48, -- coal shold be less + seed = 10, + layers={ "mudstone" }, +}) +rocks.register_ore( "coal", "default:stone_with_coal", {treshold=0, chance=85 } ) + +-- Pyrolusite Swamp +-- Diatomite Volcanic, desert +-- Glauconite Ocean 20% sandstone +-- Apatite Any Metamorphic depth +-- Zeolite Volcanic +-- Fuller's Earth Desert +-- Kaolinite Tropics + +-- +-- Misc rocks +-- + -- Limestone Sed med in Rhyolite, Andesite in mountains minetest.register_node( "rocks:limestone", { description = S("Limestone"), @@ -33,7 +54,6 @@ rocks.register_vein("limestone",{ layers={ "rhyolite", "andesite" }, }) rocks.register_ore( "limestone", "rocks:limestone", {treshold=0, chance=100} ) -rocks.register_ore( "limestone", "default:torch", {treshold=0, chance=15 } ) -- Dolomite Sed med in Rhyolite, Andesite in mountains minetest.register_node( "rocks:dolomite", { @@ -49,7 +69,6 @@ rocks.register_vein("dolomite",{ layers={ "rhyolite", "andesite" }, }) rocks.register_ore( "dolomite", "rocks:dolomite", {treshold=0, chance=100} ) -rocks.register_ore( "dolomite", "default:torch", {treshold=0, chance=15 } ) -- Quartzite MM/contact vhard sandstone From 7665588a0e8b96b91e6dfacdf91fed5d838feca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Wed, 25 Mar 2015 22:12:00 +0100 Subject: [PATCH 07/18] Debug spell fix. --- register.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/register.lua b/register.lua index 59a8217..5dc7140 100644 --- a/register.lua +++ b/register.lua @@ -26,7 +26,7 @@ rocks.register_layer=function(name,params,rock) name=name } rocks.layers_name[name]= ld - print("[rocks] layer "..ld.name.."height="..ld.height.." limit="..ld.limit) + print("[rocks] layer "..ld.name.." height="..ld.height.." limit="..ld.limit) end rocks.register_vein=function(name,params) @@ -47,8 +47,8 @@ rocks.register_vein=function(name,params) } for i,layername in pairs(params.layers) do rocks.layers_name[layername].veins[name]=rocks.veins[name] + print("[rocks] vein "..name.." in "..layername) end - print("[rocks] vein "..name) end rocks.register_ore=function( vein, node, params ) 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 08/18] 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 From 6693f103a19ff1a082bdff6dda70d99c0403e196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Thu, 2 Apr 2015 00:28:16 +0200 Subject: [PATCH 09/18] Fix, debug, cleanup. --- mapgen.lua | 125 ----------------------------------------------------- sed.lua | 38 +++++++++------- 2 files changed, 23 insertions(+), 140 deletions(-) delete mode 100644 mapgen.lua diff --git a/mapgen.lua b/mapgen.lua deleted file mode 100644 index baab9ba..0000000 --- a/mapgen.lua +++ /dev/null @@ -1,125 +0,0 @@ --- --- layer generator --- - - -minetest.register_on_generated(function(minp, maxp, seed) - stone_ctx= minetest.get_content_id("default:stone") - air_ctx= minetest.get_content_id("air") - local timebefore=os.clock(); - local manipulator, emin, emax = minetest.get_mapgen_object("voxelmanip") - local nodes = manipulator:get_data() - local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax} - local side_length = (maxp.x - minp.x) + 1 - local map_lengths_xyz = {x=side_length, y=side_length, z=side_length} - - -- sort out unused layers - -- generate noises - avl={} - for i,d in ipairs(rocks.layers) do - -- h je normaalna vyyska horného konca vrstvy - if (d.height+d.gain)>=minp.y then -- ak je to mimo zdola tak ju vyhodime - -- urobime sum pre vrstvu - local np=rocks.noiseparams_layers - np.seed=d.seed - np.scale=d.gain - np.offset=d.height - d.nmap=minetest.get_perlin_map(np,map_lengths_xyz):get2dMap_flat({x=minp.x, y=minp.z}) - -- contene_id kamenov - d.rock.ctx=d.rock.ctx or minetest.get_content_id(d.rock.node) - -- veiny - local veinstodo={} - for veinname,vd in pairs(d.veins) do - -- todo: do not generate noise for blocks outside the layer - veinstodo[veinname]=vd - end - for veinname,vd in pairs(veinstodo) do - -- noise pre vein - np=vd.np - vd.nmap=minetest.get_perlin_map(np,map_lengths_xyz):get3dMap_flat(minp) - vd.prng=PseudoRandom(np.seed) - vd.sum=0 - for i,ore in pairs(vd.ores) do - -- contntid pre rudu - ore.ctx=ore.ctx or minetest.get_content_id(ore.node) - -- sum sanci pre vein - vd.sum=vd.sum+ore.chance - end - end - table.insert(avl,d) -- pridame vrstvu - if (d.height-d.gain)>maxp.y then break end -- ak je mimo zhora tak uz dalsie nehladaj - else - --print(" no higher "..d.height.." than "..minp.y) - end - end - - -- - print("[rocks] gen2 "..os.clock()-timebefore.." #layers="..#avl.." minp.y="..minp.y.." maxp.y="..maxp.y) - for lh,ld in ipairs(avl) do - print(" "..lh.."->"..ld.name.." top="..ld.height) - for vn,vd in pairs(ld.veins) do - print(" "..vn.."->"..#vd.ores) - end - end - - local noise2d_ix = 1 - local noise3d_ix = 1 - - for z=minp.z,maxp.z,1 do - for y=minp.y,maxp.y,1 do - for x=minp.x,maxp.x,1 do - local p_pos = area:index(x, y, z) - local layer,vein - local rock - - --* select layer - for lh,ld in ipairs(avl) do - if (yvd.treshold then - vein=vd - --rock not changed - break - end - end - end - - if vein then - --* select ore - local chance=vein.prng:next(0,vein.sum) - for i,ore in pairs(vein.ores) do - chance=chance-ore.chance - if chance<=0 then - rock=ore - break - end - end - end - - --* place rocks - if (rock) and(nodes[p_pos]==stone_ctx) then - nodes[p_pos] = rock.ctx - end - - noise3d_ix =noise3d_ix+1 - noise2d_ix = noise2d_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] gen0 "..os.clock()-timebefore) -end) - diff --git a/sed.lua b/sed.lua index b4ad718..b3bd564 100644 --- a/sed.lua +++ b/sed.lua @@ -8,20 +8,20 @@ local sed={ spread = {x=80, y=80, z=80}, octaves = 0, persist = 0 }, bot={ - offset = -22, scale = 20, seed=1, + offset = -22, scale = 10, seed=1, spread = {x=80, y=80, z=80}, octaves = 2, persist = 0.7 }, primary={ name="rocks:mudstone" }, localized={}, seedseq=2, - stats={ count=0, total=0 } + stats={ count=0, total=0, node={}, totalnodes=0 } } -- Mudstone Sed soft Ocean, beach, river, glaciers minetest.register_node( "rocks:mudstone", { description = S("Mudstone"), tiles = { "rocks_Mudstone.png" }, - groups = {cracky=3, stone=1, crumbly=4}, + groups = {cracky=1, crumbly=1}, is_ground_content = true, sounds = default.node_sound_dirt_defaults(), }) @@ -30,7 +30,7 @@ minetest.register_node( "rocks:limestone", { description = S("Limestone"), tiles = { "rocks_Limestone.png" }, is_ground_content = true, sounds = default.node_sound_stone_defaults(), - groups = {cracky=CcMed, stone=1}, + groups = {cracky=2}, }) @@ -42,6 +42,7 @@ local reg=function(name,param) secondary=(param.secondary), seed=seedseq, } + sed.stats.node[name]=0 sed.seedseq=sed.seedseq+1 end rocks.register_sedimentary=reg @@ -53,11 +54,11 @@ rocks.register_sedimentary=reg --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 }) + reg("rocks:limestone", { spread=64, height=32, treshold=0.56 }) + --reg("rocks:breccia", { spread=64, height=32, treshold=0.6 }) + --reg("rocks:conglomerate", { spread=64, height=32, treshold=0.6 }) + reg("default:clay",{ spread=24, height=16, treshold=0.63 }) + reg("default:stone_with_coal", { spread=48, height=14, treshold=0.45 }) minetest.register_on_generated(function(minp, maxp, seed) if ( (sed.top.offset+sed.top.scale)>minp.y ) @@ -85,7 +86,8 @@ minetest.register_on_generated(function(minp, maxp, seed) { noise=minetest.get_perlin_map(np,map_lengths_xyz):get3dMap_flat(minp), treshold=loc.treshold, - ctx= minetest.get_content_id(name) + ctx= minetest.get_content_id(name), + ndn=name }) end local noise2d_ix = 1 @@ -98,19 +100,21 @@ minetest.register_on_generated(function(minp, maxp, seed) if (y>bottom[noise2d_ix]) and ((nodes[pos]==stone_ctx) or (nodes[pos]==dirt_ctx)) then - nodes[pos] = sed.primary.ctx + sed.stats.totalnodes=sed.stats.totalnodes+1 + if nodes[pos]==stone_ctx then nodes[pos] = air_ctx end --sed.primary.ctx for k,loc in pairs(localized) do - if (loc.noise[noise3d_ix]>loc.treshold) then + if ( loc.noise[noise3d_ix] > loc.treshold) then nodes[pos]=loc.ctx - break + sed.stats.node[loc.ndn]=sed.stats.node[loc.ndn]+1 end end end noise2d_ix=noise2d_ix+1 noise3d_ix=noise3d_ix+1 end - noise2d_ix = noise2d_ix-side_length + noise2d_ix=noise2d_ix-side_length end + noise2d_ix=noise2d_ix+side_length end manipulator:set_data(nodes) --manipulator:calc_lighting() @@ -120,11 +124,15 @@ minetest.register_on_generated(function(minp, maxp, seed) print("[rocks] sedimentary gen2 "..os.clock()-timebefore) sed.stats.count=sed.stats.count+1 sed.stats.total=sed.stats.total+(os.clock()-timebefore) + sed.stats.side=side_length 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)") + print("[rocks](sed) on_shutdown: generated total "..sed.stats.count.." chunks in "..sed.stats.total.." seconds ("..(sed.stats.total/sed.stats.count).." seconds per "..sed.stats.side.."^3 chunk)") + for name,total in pairs(sed.stats.node) do + print("[rocks](sed) "..name..": "..total.." nodes placed ("..(total*100)/(sed.stats.count*sed.stats.totalnodes).." %)") + end end) -- ~ Tomas Brod \ No newline at end of file From cd3c2b2586d95640518878240c736e4cca6f52df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Thu, 2 Apr 2015 00:35:35 +0200 Subject: [PATCH 10/18] Putising some igneous stuff from sedimentaary. --- ign.lua | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 ign.lua diff --git a/ign.lua b/ign.lua new file mode 100644 index 0000000..4761bba --- /dev/null +++ b/ign.lua @@ -0,0 +1,114 @@ +-- +-- Igneous Layer +-- + +local layer={ + top={ + offset = -13, scale = 0, + spread = {x=80, y=80, z=80}, + octaves = 0, persist = 0 }, + bot={ + offset = -180, scale = 10, seed=100, + spread = {x=80, y=80, z=80}, + octaves = 2, persist = 0.7 }, + primary={ name="rocks:basalt" }, + localized={}, + seedseq=100, + stats={ count=0, total=0, node={}, totalnodes=0 } +} + +-- more rock defs + + +local reg=function(name,param) + layer.localized[name]={ + spread=(param.spread or 20), + height=(param.height or 15), + treshold=(param.treshold or 0.85), + secondary=(param.secondary), + seed=seedseq, + } + layer.stats.node[name]=0 + layer.seedseq=layer.seedseq+1 +end +rocks.register_igneous=reg + +-- rock registration + --eg: reg("default:stone_with_coal", { spread=48, height=14, treshold=0.45 }) + +minetest.register_on_generated(function(minp, maxp, seed) + if ( (layer.top.offset+layer.top.scale)>minp.y ) + and ( (layer.bot.offset-layer.bot.scale)bottom[noise2d_ix]) + and ((nodes[pos]==stone_ctx) or (nodes[pos]==dirt_ctx)) + then + layer.stats.totalnodes=layer.stats.totalnodes+1 + if nodes[pos]==stone_ctx then nodes[pos] = air_ctx end --layer.primary.ctx + for k,loc in pairs(localized) do + if ( loc.noise[noise3d_ix] > loc.treshold) then + nodes[pos]=loc.ctx + layer.stats.node[loc.ndn]=layer.stats.node[loc.ndn]+1 + end + end + end + noise2d_ix=noise2d_ix+1 + noise3d_ix=noise3d_ix+1 + end + noise2d_ix=noise2d_ix-side_length + end + noise2d_ix=noise2d_ix+side_length + end + manipulator:set_data(nodes) + --manipulator:calc_lighting() + manipulator:set_lighting({day=15,night=15}) + --manipulator:update_liquids() + manipulator:write_to_map() + print("[rocks] igneous gen2 "..os.clock()-timebefore) + layer.stats.count=layer.stats.count+1 + layer.stats.total=layer.stats.total+(os.clock()-timebefore) + layer.stats.side=side_length + end +end) + +minetest.register_on_shutdown(function() + print("[rocks](ign) on_shutdown: generated total "..layer.stats.count.." chunks in "..layer.stats.total.." seconds ("..(layer.stats.total/layer.stats.count).." seconds per "..layer.stats.side.."^3 chunk)") + for name,total in pairs(layer.stats.node) do + print("[rocks](ign) "..name..": "..total.." nodes placed ("..(total*100)/(layer.stats.count*layer.stats.totalnodes).." %)") + end +end) + +-- ~ Tomas Brod \ No newline at end of file From 21d2a4779d9220f7ae2b8392d931e05db1f1dca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Thu, 2 Apr 2015 20:17:56 +0200 Subject: [PATCH 11/18] Rewrite igneous layer. --- geologicaLayers.lua | 126 -------------------------------------------- geologicaStrata.lua | 75 -------------------------- geologicaVeins.lua | 15 ------ ign.lua | 124 ++++++++++++++----------------------------- init.lua | 10 ++-- mapgen.lua | 99 ++++++++++++++++++++++++++++++++++ sed.lua | 96 +++++---------------------------- testing.lua | 12 ----- 8 files changed, 157 insertions(+), 400 deletions(-) delete mode 100644 geologicaLayers.lua delete mode 100644 geologicaStrata.lua delete mode 100644 geologicaVeins.lua create mode 100644 mapgen.lua delete mode 100644 testing.lua diff --git a/geologicaLayers.lua b/geologicaLayers.lua deleted file mode 100644 index c414b19..0000000 --- a/geologicaLayers.lua +++ /dev/null @@ -1,126 +0,0 @@ -local CcHard=3 -local CcStrong=3 -local CcMed=3 -local CcSoft=3 - --- --- Main rocks (top to bottom) --- - --- Granite In/Felsic hard Very common, below sed on land -minetest.register_node( "rocks:granite", { - description = S("Granite"), - tiles = { "rocks_Granite.png" }, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), - groups = {cracky=CcStrong, stone=1}, -}) -rocks.register_layer( "granite",{ gain=20, height=-22, limit=2, seed=1 }, "rocks:granite") - --- Diorite In/Inter vhard Below granite -minetest.register_node( "rocks:diorite", { - description = S("Diorite"), - tiles = { "rocks_Diorite.png" }, - groups = {cracky=CcHard, stone=1}, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), -}) -rocks.register_layer( "diorite",{ gain=20, height=-55, limit=2, seed=2 }, "rocks:diorite") - --- Basalt Ex/Mafic hard same as diorite, byt limit=0.5 -minetest.register_node( "rocks:basalt", { - description = S("Basalt"), - tiles = { "rocks_Basalt.png" }, - groups = {cracky=CcStrong, stone=1}, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), -}) -rocks.register_layer( "basalt",{ gain=20, height=-60, limit=-0.7, seed=2 }, "rocks:basalt") - --- Gabbro In/Mafic vhard Below basalt/diorite (mtns, ocean) -minetest.register_node( "rocks:gabbro", { - description = S("Gabbro"), - tiles = { "rocks_Gabbro.png" }, - groups = {cracky=CcHard, stone=1}, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), -}) -rocks.register_layer( "gabbro",{ gain=20, height=-70, limit=2, seed=3 }, "rocks:gabbro") - --- Peridotite In/UMafic vhard Rarely under gabbro -minetest.register_node( "rocks:peridotite", { - description = S("Peridotite"), - tiles = { "rocks_Peridotite.png" }, - groups = {cracky=CcStrong, stone=1}, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), -}) -rocks.register_layer( "peridotite",{ gain=20, height=-120, limit=-0.8, seed=4 }, "rocks:peridotite") - --- Komatiite Ex/UMafic - Too deep -minetest.register_node( "rocks:komatiite", { - description = S("Komatiite"), - tiles = { "default_stone.png" }, -- no texture, yet - groups = {cracky=CcHard, stone=1}, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), -}) -rocks.register_layer( "komatiite",{ gain=20, height=-130, limit=2, seed=5 }, "rocks:komatiite") - --- --- top sedimentary rocks --- - --- Mudstone Sed soft Ocean, beach, river, glaciers -minetest.register_node( "rocks:mudstone", { - description = S("Mudstone"), - tiles = { "rocks_Mudstone.png" }, - groups = {cracky=CcSoft, stone=1}, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), -}) -rocks.register_layer( "mudstone",{ gain=10, height=10, limit=2, seed=4 }, "rocks:mudstone") - --- Slate MM/barro med Under mud/clay/siltstone -minetest.register_node( "rocks:slate", { - description = S("slate"), - tiles = { "rocks_Slate.png" }, - groups = {cracky=CcMed, stone=1}, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), -}) --- rocks.register_layer( "slate",{ gain=10, height=-7, limit=2, seed=5 }, "rocks:slate") - --- Schist MM/barro med Under slate, sometimes igneous -minetest.register_node( "rocks:schist", { - description = S("schist"), - tiles = { "rocks_Schist.png" }, - groups = {cracky=CcMed, stone=1}, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), -}) -rocks.register_layer( "schist",{ gain=10, height=-15, limit=2, seed=5 }, "rocks:schist") - --- Gneiss MM/barro hard Under schist, sometimes igneous -minetest.register_node( "rocks:gneiss", { - description = S("gneiss"), - tiles = { "rocks_Gneiss.png" }, - groups = {cracky=CcStrong, stone=1}, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), -}) -rocks.register_layer( "gneiss",{ gain=10, height=-19, limit=2, seed=6 }, "rocks:gneiss") - --- --- peak rocks --- - --- Rhyolite Ex/Felsic hard Mountains, top -minetest.register_node( "rocks:rhyolite", { - description = S("Rhyolite"), - tiles = { "rocks_Rhyolite.png" }, - groups = {cracky=CcHard, stone=1}, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), -}) -rocks.register_layer( "rhyolite",{ gain=8, height=80, limit=2, seed=4 }, "rocks:rhyolite") - --- Andesite Ex/Inter hard Mountains, below rhyolite -minetest.register_node( "rocks:andesite", { - description = S("Andesite"), - tiles = { "rocks_Andesite.png" }, - groups = {cracky=CcHard, stone=1}, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), -}) -rocks.register_layer( "andesite",{ gain=8, height=22, limit=2, seed=4 }, "rocks:andesite") - -print("[rocks/geologicaLayers] loaded.") diff --git a/geologicaStrata.lua b/geologicaStrata.lua deleted file mode 100644 index b9abeef..0000000 --- a/geologicaStrata.lua +++ /dev/null @@ -1,75 +0,0 @@ -local CcHard=3 -local CcStrong=3 -local CcMed=3 -local CcSoft=3 - --- --- Sedimentary --- - --- Claystone Sed soft in mudstone -rocks.register_vein("clay",{ - spread = {x=30, y=10, z=30}, - treshold=0.26, -- clay should be plenty - seed = 9, - layers={ "mudstone" }, -}) -rocks.register_ore( "clay", "default:clay", {treshold=0, chance=85 } ) - --- Breccia Mixture soft in mudstone --- Conglomerate Sed soft in mudstone - --- Coal Ocean, inland 2x swamp -rocks.register_vein("coal",{ - spread = {x=20, y=10, z=20}, - treshold=0.48, -- coal shold be less - seed = 10, - layers={ "mudstone" }, -}) -rocks.register_ore( "coal", "default:stone_with_coal", {treshold=0, chance=85 } ) - --- Pyrolusite Swamp --- Diatomite Volcanic, desert --- Glauconite Ocean 20% sandstone --- Apatite Any Metamorphic depth --- Zeolite Volcanic --- Fuller's Earth Desert --- Kaolinite Tropics - --- --- Misc rocks --- - --- Limestone Sed med in Rhyolite, Andesite in mountains -minetest.register_node( "rocks:limestone", { - description = S("Limestone"), - tiles = { "rocks_Limestone.png" }, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), - groups = {cracky=CcMed, stone=1}, -}) -rocks.register_vein("limestone",{ - spread = {x=60, y=60, z=60}, - treshold=0.4, - seed = 10, - layers={ "rhyolite", "andesite" }, -}) -rocks.register_ore( "limestone", "rocks:limestone", {treshold=0, chance=100} ) - --- Dolomite Sed med in Rhyolite, Andesite in mountains -minetest.register_node( "rocks:dolomite", { - description = S("Dolomite"), - tiles = { "rocks_Dolomite.png" }, - is_ground_content = true, sounds = default.node_sound_stone_defaults(), - groups = {cracky=CcMed, stone=1}, -}) -rocks.register_vein("dolomite",{ - spread = {x=60, y=60, z=60}, - treshold=0.4, - seed = 11, - layers={ "rhyolite", "andesite" }, -}) -rocks.register_ore( "dolomite", "rocks:dolomite", {treshold=0, chance=100} ) - --- Quartzite MM/contact vhard sandstone - -print("[rocks/geologicaStrata] loaded.") \ No newline at end of file diff --git a/geologicaVeins.lua b/geologicaVeins.lua deleted file mode 100644 index 13ddb52..0000000 --- a/geologicaVeins.lua +++ /dev/null @@ -1,15 +0,0 @@ -local CcHard=3 -local CcStrong=3 -local CcMed=3 -local CcSoft=3 - --- --- Veins --- - --- Skarn MM/contact med in rhyo/ande in mountains --- Hornfels MM/contact vhard in skarn --- Marble MM/contact hard in skarn --- Limestone Sed med in skarn - -print("[rocks/geologicaVeins] loaded.") diff --git a/ign.lua b/ign.lua index 4761bba..152be4a 100644 --- a/ign.lua +++ b/ign.lua @@ -2,112 +2,68 @@ -- Igneous Layer -- -local layer={ +local ign={ top={ - offset = -13, scale = 0, + offset = -10, scale = 0, spread = {x=80, y=80, z=80}, octaves = 0, persist = 0 }, bot={ - offset = -180, scale = 10, seed=100, + offset = -180, scale = 10, seed=rocksl.GetNextSeed(), spread = {x=80, y=80, z=80}, octaves = 2, persist = 0.7 }, primary={ name="rocks:basalt" }, localized={}, - seedseq=100, - stats={ count=0, total=0, node={}, totalnodes=0 } + stats={ count=0, total=0, node={}, totalnodes=0 }, + debugging=0 } --- more rock defs +-- Basalt Ex/Mafic hard same as diorite, byt limit=0.5 +minetest.register_node( "rocks:basalt", { + description = S("Basalt"), + tiles = { "rocks_Basalt.png" }, + groups = {cracky=3, stone=1}, + is_ground_content = true, sounds = default.node_sound_stone_defaults(), +}) +-- more rock defs +minetest.register_node( "rocks:granite", { + description = S("Granite"), + tiles = { "rocks_Granite.png" }, + is_ground_content = true, sounds = default.node_sound_stone_defaults(), + groups = {cracky=3, stone=1}, +}) +minetest.register_node( "rocks:diorite", { + description = S("Diorite"), + tiles = { "rocks_Diorite.png" }, + groups = {cracky=3, stone=1}, + is_ground_content = true, sounds = default.node_sound_stone_defaults(), +}) +minetest.register_node( "rocks:gabbro", { + description = S("Gabbro"), + tiles = { "rocks_Gabbro.png" }, + groups = {cracky=3, stone=1}, + is_ground_content = true, sounds = default.node_sound_stone_defaults(), +}) local reg=function(name,param) - layer.localized[name]={ - spread=(param.spread or 20), - height=(param.height or 15), - treshold=(param.treshold or 0.85), - secondary=(param.secondary), - seed=seedseq, - } - layer.stats.node[name]=0 - layer.seedseq=layer.seedseq+1 + rocksl.register_blob(ign,name,param) end rocks.register_igneous=reg -- rock registration - --eg: reg("default:stone_with_coal", { spread=48, height=14, treshold=0.45 }) + reg("rocks:granite", { spread=40, height=32, treshold=0.04}) + reg("rocks:diorite", { spread=40, height=32, treshold=0.24}) + reg("rocks:gabbro", { spread=40, height=32, treshold=0.33}) minetest.register_on_generated(function(minp, maxp, seed) - if ( (layer.top.offset+layer.top.scale)>minp.y ) - and ( (layer.bot.offset-layer.bot.scale)bottom[noise2d_ix]) - and ((nodes[pos]==stone_ctx) or (nodes[pos]==dirt_ctx)) - then - layer.stats.totalnodes=layer.stats.totalnodes+1 - if nodes[pos]==stone_ctx then nodes[pos] = air_ctx end --layer.primary.ctx - for k,loc in pairs(localized) do - if ( loc.noise[noise3d_ix] > loc.treshold) then - nodes[pos]=loc.ctx - layer.stats.node[loc.ndn]=layer.stats.node[loc.ndn]+1 - end - end - end - noise2d_ix=noise2d_ix+1 - noise3d_ix=noise3d_ix+1 - end - noise2d_ix=noise2d_ix-side_length - end - noise2d_ix=noise2d_ix+side_length - end - manipulator:set_data(nodes) - --manipulator:calc_lighting() - manipulator:set_lighting({day=15,night=15}) - --manipulator:update_liquids() - manipulator:write_to_map() - print("[rocks] igneous gen2 "..os.clock()-timebefore) - layer.stats.count=layer.stats.count+1 - layer.stats.total=layer.stats.total+(os.clock()-timebefore) - layer.stats.side=side_length - end + rocksl.layergen(ign,minp,maxp,seed) end) minetest.register_on_shutdown(function() - print("[rocks](ign) on_shutdown: generated total "..layer.stats.count.." chunks in "..layer.stats.total.." seconds ("..(layer.stats.total/layer.stats.count).." seconds per "..layer.stats.side.."^3 chunk)") - for name,total in pairs(layer.stats.node) do - print("[rocks](ign) "..name..": "..total.." nodes placed ("..(total*100)/(layer.stats.count*layer.stats.totalnodes).." %)") + if (ign.stats.count==0) then print("[rocks](ign) stats not available, no chunks generated") return end + print("[rocks](ign) generated total "..ign.stats.count.." chunks in "..ign.stats.total.." seconds ("..(ign.stats.total/ign.stats.count).." seconds per "..ign.stats.side.."^3 chunk)") + for name,total in pairs(ign.stats.node) do + print("[rocks](ign) "..name..": "..total.." nodes placed ("..(total*100)/(ign.stats.totalnodes).." %)") end end) diff --git a/init.lua b/init.lua index a81ea09..7523f51 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,5 @@ +print("[rocks] mod initializing") + -- Load translation library if intllib is installed if (minetest.get_modpath("intllib")) then @@ -8,16 +10,14 @@ if (minetest.get_modpath("intllib")) then end rocks={} +rocksl={} local modpath=minetest.get_modpath(minetest.get_current_modname()) -print("[rocks] begin") - +dofile(modpath.."/mapgen.lua") dofile(modpath.."/sed.lua") +dofile(modpath.."/ign.lua") minetest.register_on_mapgen_init(function(mapgen_params) -- todo: disable caves and ores - print("[rocks] mapgen initalized ") end) - -print("[rocks] done") \ No newline at end of file diff --git a/mapgen.lua b/mapgen.lua new file mode 100644 index 0000000..43a0743 --- /dev/null +++ b/mapgen.lua @@ -0,0 +1,99 @@ +-- +-- layer generator +-- + +rocksl.seedseq=0 +rocksl.GetNextSeed=function() + rocksl.seedseq=rocksl.seedseq+20 + print("seed "..rocksl.seedseq) + return rocksl.seedseq +end + +rocksl.register_blob=function(layer,name,param) + layer.localized[name]={ + spread=(param.spread or 20), + height=(param.height or 15), + treshold=(param.treshold or 0.85), + secondary=param.secondary, + seed=(rocksl.GetNextSeed()), + } + layer.stats.node[name]=0 +end + +rocksl.layergen=function(layer, minp, maxp, seed) + if ( (layer.top.offset+layer.top.scale)>minp.y ) + and ( (layer.bot.offset-layer.bot.scale)bottom[noise2d_ix]) + and ((nodes[pos]==stone_ctx) or (nodes[pos]==dirt_ctx)) + then + layer.stats.totalnodes=layer.stats.totalnodes+1 + if nodes[pos]==stone_ctx then nodes[pos] = layer.primary.ctx end + for k,loc in pairs(localized) do + if ( loc.noise[noise3d_ix] > loc.treshold) then + nodes[pos]=loc.ctx + layer.stats.node[loc.ndn]=layer.stats.node[loc.ndn]+1 + break + end + end + end + noise2d_ix=noise2d_ix+1 + noise3d_ix=noise3d_ix+1 + end + noise2d_ix=noise2d_ix-side_length + end + noise2d_ix=noise2d_ix+side_length + end + print("after loop: "..(os.clock()-timebefore)) + manipulator:set_data(nodes) + --manipulator:calc_lighting() + --manipulator:update_liquids() + if layer.debugging then + manipulator:set_lighting({day=15,night=15}) + end + manipulator:write_to_map() + print("after commit: "..(os.clock()-timebefore)) + layer.stats.count=layer.stats.count+1 + layer.stats.total=layer.stats.total+(os.clock()-timebefore) + layer.stats.side=side_length + end +end + +-- ~ Tomas Brod \ No newline at end of file diff --git a/sed.lua b/sed.lua index b3bd564..bcd7e6e 100644 --- a/sed.lua +++ b/sed.lua @@ -8,20 +8,20 @@ local sed={ spread = {x=80, y=80, z=80}, octaves = 0, persist = 0 }, bot={ - offset = -22, scale = 10, seed=1, + offset = -16, scale = 10, seed=rocksl.GetNextSeed(), spread = {x=80, y=80, z=80}, octaves = 2, persist = 0.7 }, primary={ name="rocks:mudstone" }, localized={}, - seedseq=2, - stats={ count=0, total=0, node={}, totalnodes=0 } + stats={ count=0, total=0, node={}, totalnodes=0 }, + debugging=nil } -- Mudstone Sed soft Ocean, beach, river, glaciers minetest.register_node( "rocks:mudstone", { description = S("Mudstone"), tiles = { "rocks_Mudstone.png" }, - groups = {cracky=1, crumbly=1}, + groups = {cracky=1, crumbly=3}, is_ground_content = true, sounds = default.node_sound_dirt_defaults(), }) @@ -35,16 +35,9 @@ minetest.register_node( "rocks:limestone", { local reg=function(name,param) - sed.localized[name]={ - spread=(param.spread or 20), - height=(param.height or 15), - treshold=(param.treshold or 0.85), - secondary=(param.secondary), - seed=seedseq, - } - sed.stats.node[name]=0 - sed.seedseq=sed.seedseq+1 + rocksl.register_blob(sed,name,param) end + rocks.register_sedimentary=reg -- Sedimentary rock hardness and distribution @@ -54,84 +47,21 @@ rocks.register_sedimentary=reg --Conglomerate Weak Localized continental, folded -->Limestone Medium Localized continental, folded; primary oceanic, hills -->Coal - Large beds, twice as common in swamps - reg("rocks:limestone", { spread=64, height=32, treshold=0.56 }) + reg("rocks:limestone", { spread=64, height=32, treshold=0.36 }) --reg("rocks:breccia", { spread=64, height=32, treshold=0.6 }) --reg("rocks:conglomerate", { spread=64, height=32, treshold=0.6 }) - reg("default:clay",{ spread=24, height=16, treshold=0.63 }) - reg("default:stone_with_coal", { spread=48, height=14, treshold=0.45 }) + reg("default:clay",{ spread=48, height=14, treshold=0.50 }) + reg("default:stone_with_coal", { spread=48, height=14, treshold=0.40 }) 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 - sed.stats.totalnodes=sed.stats.totalnodes+1 - if nodes[pos]==stone_ctx then nodes[pos] = air_ctx end --sed.primary.ctx - for k,loc in pairs(localized) do - if ( loc.noise[noise3d_ix] > loc.treshold) then - nodes[pos]=loc.ctx - sed.stats.node[loc.ndn]=sed.stats.node[loc.ndn]+1 - end - end - end - noise2d_ix=noise2d_ix+1 - noise3d_ix=noise3d_ix+1 - end - noise2d_ix=noise2d_ix-side_length - end - noise2d_ix=noise2d_ix+side_length - 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) - sed.stats.side=side_length - end + rocksl.layergen(sed,minp,maxp,seed) 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 "..sed.stats.side.."^3 chunk)") + if (sed.stats.count==0) then print("[rocks](sed) stats not available, no chunks generated") return end + print("[rocks](sed) generated total "..sed.stats.count.." chunks in "..sed.stats.total.." seconds ("..(sed.stats.total/sed.stats.count).." seconds per "..sed.stats.side.."^3 chunk)") for name,total in pairs(sed.stats.node) do - print("[rocks](sed) "..name..": "..total.." nodes placed ("..(total*100)/(sed.stats.count*sed.stats.totalnodes).." %)") + print("[rocks](sed) "..name..": "..total.." nodes placed ("..(total*100)/(sed.stats.totalnodes).." %)") end end) diff --git a/testing.lua b/testing.lua deleted file mode 100644 index 8a65aac..0000000 --- a/testing.lua +++ /dev/null @@ -1,12 +0,0 @@ -rocks.register_layer("testl", { gain=20, height=-55, limit=2, seed=1 }, "default:wood") - -rocks.register_vein("clay",{ - spread = {x=30, y=10, z=30}, - treshold=0.2, -- clay should be plenty - seed = 9, - hmin=-8, hmax=nil, - layers={ "mudstone" }, -}) - -rocks.register_ore( "clay", "default:clay", {treshold=0, chance=85 } ) -rocks.register_ore( "clay", "default:torch", {treshold=0, chance=15 } ) From 292ad18921f63f68cbc21817d40e0b33fddf7844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Thu, 2 Apr 2015 20:31:01 +0200 Subject: [PATCH 12/18] update doc of the new host and the rewrite --- a.txt | 83 +++-------------------------------------------------------- 1 file changed, 3 insertions(+), 80 deletions(-) diff --git a/a.txt b/a.txt index 0c66864..29549d3 100644 --- a/a.txt +++ b/a.txt @@ -15,7 +15,8 @@ Features ** Work in progress! ** -* Git clone: [https](https://gitorious.org/mt/rocks.git) +* git clone git://repo.or.cz/rocks.git ([show](http://repo.or.cz/rocks.git/)) +* (old) Git clone: [https](https://gitorious.org/mt/rocks.git) Screenshots ----------- @@ -29,82 +30,4 @@ Documentation How the underground is generated: *todo*. -Underground is divided into horizontal layers. Bottom of each layer is at -fixed height and moved up or down by 2d perlin noise. - -In every layer there can be multiple veins. Veins are blob-shaped volumes -of different rocks. Borders of vein are defined by 3d perlin noise. Veins -often contain ores. - -In every vein, ores are distributed randomly. Some ores -may occur in specific areas of the vein (where noise is higher than -treshold) or distributed randomly in specific amount (chance based on -pseudorandom number) or combination of both. - -There is 1 2d perlin noise per layer, 1 3d perlin noise per vein and 1 -pseudorandom number generator per ore. - -Modding Interface ------------------ - -"Rocks" exposes api to add new ores, veins and layers. The api is defined -in [register](register.lua). - -### Register layer - - rocks.register_layer=function(name,params,rock) - - -This function registers a layer. Layer is identified by unique string name. -Location of layer is specified in params and node, the layer should be -composed of is defined by rock. - -Field "params.gain" sets how height of the layer should vary. Field -"params.height" sets height of bottom of the layer. Field "params.limit" is -value of noise above which the layer is not generated. Set to 2 to disable -this feature. Last field "params.seed" is offset to world seed to seed the -noise. - -### Register vein - - rocks.register_vein=function(name,params) - -This function registers a vein with name "name" to be generated according -to params. - -Field "params.spread" {x,y,z} defines how the vein should look like. X -shoudd be equal to z. If y=x=z then the vein is equal in all directions. To -make the vein taller, set y to higher value. Larger values make larger and -less frequent veins. - -Field "params.treshold" specifies rarity of the vein. It should be betveen --2 and +2, mapgen will use this or per-ore treshold if per-ore treshold is -larger. - -- 2 never generate -- 1 extremly rare -- 0 50% chance -- less than 0 = SPAM - -Field "params.seed" is added to world seed to form seed for noise function. - -Depths, where the wein should generate can be controlled by fields hmin and -hmax. They can be set to nil to generate everywhere. - -Layers, where the vein should generate in must be listed in Field -"params.layer". - -## Register ore - - rocks.register_ore=function( vein, node, params ) - -This function registers ore or rock to be generated in vein "vein". Node to -be generated is "node". Params specify parameters, where the rock should -spawn. - -If noise is larger than Params.treshold, the ore is spawned (set to 2 to -spawn everywhere in the vein, 0.8=only in middle). Params.chance specify -the chance (/100%) of ore being spawned (0=never 1=always 0.5=50%). - -If multiple ores pass the treshhold and chance tests, ore with highest -treshold and smallest chance is spawned. +Mod has been rewritten, so no doc yet. From 57b51fa10f57c794c65ef0c2d2227dc0517a7ed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Thu, 2 Apr 2015 21:14:05 +0200 Subject: [PATCH 13/18] disable debug --- ign.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ign.lua b/ign.lua index 152be4a..0476382 100644 --- a/ign.lua +++ b/ign.lua @@ -14,7 +14,7 @@ local ign={ primary={ name="rocks:basalt" }, localized={}, stats={ count=0, total=0, node={}, totalnodes=0 }, - debugging=0 + debugging=nil } -- Basalt Ex/Mafic hard same as diorite, byt limit=0.5 From f02a668c22e4795c8834409ea10cbc5d55952106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Fri, 3 Apr 2015 15:48:49 +0200 Subject: [PATCH 14/18] Better logging system. --- ign.lua | 6 +++--- init.lua | 6 +++++- mapgen.lua | 14 +++++++++----- sed.lua | 6 +++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/ign.lua b/ign.lua index 0476382..c83f71a 100644 --- a/ign.lua +++ b/ign.lua @@ -60,10 +60,10 @@ minetest.register_on_generated(function(minp, maxp, seed) end) minetest.register_on_shutdown(function() - if (ign.stats.count==0) then print("[rocks](ign) stats not available, no chunks generated") return end - print("[rocks](ign) generated total "..ign.stats.count.." chunks in "..ign.stats.total.." seconds ("..(ign.stats.total/ign.stats.count).." seconds per "..ign.stats.side.."^3 chunk)") + if (ign.stats.count==0) then rocksl.print("[rocks](ign) stats not available, no chunks generated") return end + rocksl.print("[rocks](ign) generated total "..ign.stats.count.." chunks in "..ign.stats.total.." seconds ("..(ign.stats.total/ign.stats.count).." seconds per "..ign.stats.side.."^3 chunk)") for name,total in pairs(ign.stats.node) do - print("[rocks](ign) "..name..": "..total.." nodes placed ("..(total*100)/(ign.stats.totalnodes).." %)") + rocksl.print("[rocks](ign) "..name..": "..total.." nodes placed ("..(total*100)/(ign.stats.totalnodes).." %)") end end) diff --git a/init.lua b/init.lua index 7523f51..b780a51 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,4 @@ -print("[rocks] mod initializing") +minetest.log("info","[rocks] mod initializing") -- Load translation library if intllib is installed @@ -12,6 +12,10 @@ end rocks={} rocksl={} +rocksl.print=function(text) + print("[rocks] "..text) +end + local modpath=minetest.get_modpath(minetest.get_current_modname()) dofile(modpath.."/mapgen.lua") diff --git a/mapgen.lua b/mapgen.lua index 43a0743..a7e1c8e 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -2,10 +2,14 @@ -- layer generator -- +local print2=function(text) + minetest.log("verbose","rocks/gen/ "..text) +end + rocksl.seedseq=0 rocksl.GetNextSeed=function() rocksl.seedseq=rocksl.seedseq+20 - print("seed "..rocksl.seedseq) + print2("seed "..rocksl.seedseq) return rocksl.seedseq end @@ -56,13 +60,13 @@ rocksl.layergen=function(layer, minp, maxp, seed) end local noise2d_ix = 1 local noise3d_ix = 1 - print("after noise: "..(os.clock()-timebefore)) + print2("after noise: "..(os.clock()-timebefore)) for z=minp.z,maxp.z,1 do for y=minp.y,maxp.y,1 do for x=minp.x,maxp.x,1 do local pos = area:index(x, y, z) if (y>bottom[noise2d_ix]) - and ((nodes[pos]==stone_ctx) or (nodes[pos]==dirt_ctx)) + and (nodes[pos]~=air_ctx) then layer.stats.totalnodes=layer.stats.totalnodes+1 if nodes[pos]==stone_ctx then nodes[pos] = layer.primary.ctx end @@ -81,7 +85,7 @@ rocksl.layergen=function(layer, minp, maxp, seed) end noise2d_ix=noise2d_ix+side_length end - print("after loop: "..(os.clock()-timebefore)) + print2("after loop: "..(os.clock()-timebefore)) manipulator:set_data(nodes) --manipulator:calc_lighting() --manipulator:update_liquids() @@ -89,7 +93,7 @@ rocksl.layergen=function(layer, minp, maxp, seed) manipulator:set_lighting({day=15,night=15}) end manipulator:write_to_map() - print("after commit: "..(os.clock()-timebefore)) + print2("after commit: "..(os.clock()-timebefore)) layer.stats.count=layer.stats.count+1 layer.stats.total=layer.stats.total+(os.clock()-timebefore) layer.stats.side=side_length diff --git a/sed.lua b/sed.lua index bcd7e6e..11e7a7b 100644 --- a/sed.lua +++ b/sed.lua @@ -58,10 +58,10 @@ minetest.register_on_generated(function(minp, maxp, seed) end) minetest.register_on_shutdown(function() - if (sed.stats.count==0) then print("[rocks](sed) stats not available, no chunks generated") return end - print("[rocks](sed) generated total "..sed.stats.count.." chunks in "..sed.stats.total.." seconds ("..(sed.stats.total/sed.stats.count).." seconds per "..sed.stats.side.."^3 chunk)") + if (sed.stats.count==0) then rocksl.print("[rocks](sed) stats not available, no chunks generated") return end + rocksl.print("[rocks](sed) generated total "..sed.stats.count.." chunks in "..sed.stats.total.." seconds ("..(sed.stats.total/sed.stats.count).." seconds per "..sed.stats.side.."^3 chunk)") for name,total in pairs(sed.stats.node) do - print("[rocks](sed) "..name..": "..total.." nodes placed ("..(total*100)/(sed.stats.totalnodes).." %)") + rocksl.print("[rocks](sed) "..name..": "..total.." nodes placed ("..(total*100)/(sed.stats.totalnodes).." %)") end end) From dbbd865125bb4eddeda95d0f63a4f94c8f165fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Fri, 3 Apr 2015 16:06:45 +0200 Subject: [PATCH 15/18] Preserving order of registered strata, fixed some noise params, added upper boundary check to mapgen. --- ign.lua | 6 +++--- mapgen.lua | 15 ++++++++------- sed.lua | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ign.lua b/ign.lua index c83f71a..4bb27b7 100644 --- a/ign.lua +++ b/ign.lua @@ -51,9 +51,9 @@ end rocks.register_igneous=reg -- rock registration - reg("rocks:granite", { spread=40, height=32, treshold=0.04}) - reg("rocks:diorite", { spread=40, height=32, treshold=0.24}) - reg("rocks:gabbro", { spread=40, height=32, treshold=0.33}) + reg("rocks:granite", { spread=40, height=32, treshold=0.06}) + reg("rocks:diorite", { spread=40, height=32, treshold=0.23}) + reg("rocks:gabbro", { spread=40, height=32, treshold=0.36}) minetest.register_on_generated(function(minp, maxp, seed) rocksl.layergen(ign,minp,maxp,seed) diff --git a/mapgen.lua b/mapgen.lua index a7e1c8e..68aba29 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -14,13 +14,14 @@ rocksl.GetNextSeed=function() end rocksl.register_blob=function(layer,name,param) - layer.localized[name]={ + table.insert(layer.localized,{ + primary=name, spread=(param.spread or 20), height=(param.height or 15), treshold=(param.treshold or 0.85), secondary=param.secondary, seed=(rocksl.GetNextSeed()), - } + }) layer.stats.node[name]=0 end @@ -45,7 +46,7 @@ rocksl.layergen=function(layer, minp, maxp, seed) -- noises: local bottom=minetest.get_perlin_map(layer.bot,map_lengths_xyz):get2dMap_flat({x=minp.x, y=minp.z}) local localized={} - for name,loc in pairs(layer.localized) do + for _,loc in ipairs(layer.localized) do --defaults and overrides local np={ offset = 0, scale = 1, octaves = 1, persist = 0.7, spread = {x=loc.spread, y=loc.height, z=loc.spread}, seed=loc.seed} @@ -54,8 +55,8 @@ rocksl.layergen=function(layer, minp, maxp, seed) { noise=minetest.get_perlin_map(np,map_lengths_xyz):get3dMap_flat(minp), treshold=loc.treshold, - ctx= minetest.get_content_id(name), - ndn=name + ctx= minetest.get_content_id(loc.primary), + ndn=loc.primary }) end local noise2d_ix = 1 @@ -65,8 +66,8 @@ rocksl.layergen=function(layer, minp, maxp, seed) for y=minp.y,maxp.y,1 do for x=minp.x,maxp.x,1 do local pos = area:index(x, y, z) - if (y>bottom[noise2d_ix]) - and (nodes[pos]~=air_ctx) + if (y>bottom[noise2d_ix]) and (y Date: Fri, 3 Apr 2015 21:32:20 +0200 Subject: [PATCH 16/18] Experimental vein generator based on sphere deformed vith 3D noise. The nyan cat is a bonus :) --- ign.lua | 18 ++++++++++++++++++ mapgen.lua | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/ign.lua b/ign.lua index 4bb27b7..3579a56 100644 --- a/ign.lua +++ b/ign.lua @@ -55,8 +55,26 @@ rocks.register_igneous=reg reg("rocks:diorite", { spread=40, height=32, treshold=0.23}) 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=10, + --radius={ average=15, amplitude=6 }, + 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 + } + } + } +} + minetest.register_on_generated(function(minp, maxp, seed) rocksl.layergen(ign,minp,maxp,seed) + rocksl.veingen(sample_vein_col,minp,maxp,seed) end) minetest.register_on_shutdown(function() diff --git a/mapgen.lua b/mapgen.lua index 68aba29..4550d85 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -101,4 +101,37 @@ rocksl.layergen=function(layer, minp, maxp, seed) end end +rocksl.veingen=function(veins,minp,maxp,seed) + local side_length=(maxp.y-minp.y) + local random=PseudoRandom(seed-79) + local noise=minetest.get_perlin(-79,1,0.7,8) + print("begin veingen") + for _,vein in ipairs(veins) do + if (minp.yvein.maxy) then + local iterations_count= (vein.rarity*side_length)^3 + iterations_count=iterations_count+random:next(-1,1) + for iteration=1, iterations_count do + local x0=minp.x+ random:next(0,side_length) + local y0=minp.y+ random:next(0,side_length) + local z0=minp.z+ random:next(0,side_length) + if true or (minetest.get_node({x0,y0,z0}).name==vein.wherein) then + print("vein "..vein.primary.." @ "..x0..","..y0..","..z0) + for x=-vein.radius, vein.radius do + for y=-vein.radius, vein.radius do + for z=-vein.radius, vein.radius do + p={x=x+x0,y=y+y0,z=z+z0} + local nv=noise:get3d(p)*5 + if ((x^2)+(y^2)+(z^2))<((vein.radius+nv)^2) then + minetest.set_node(p, {name=vein.primary}) + end + end end end + else + print("vein "..vein.primary.." bad environmnent") + end + end + end + end + print("end veingen") +end + -- ~ Tomas Brod \ No newline at end of file From 4d7d8cd80dd916bbcb97213dd7e6b68e2665d11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Fri, 3 Apr 2015 23:54:50 +0200 Subject: [PATCH 17/18] Vein generator finished and use flat noisemap and vox'ma'nips. --- ign.lua | 3 +-- mapgen.lua | 63 ++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/ign.lua b/ign.lua index 3579a56..9ba1ea8 100644 --- a/ign.lua +++ b/ign.lua @@ -60,8 +60,7 @@ local sample_vein_col={ { primary="default:nyancat", wherein="rocks:granite", miny=-160, maxy=20, - radius=10, - --radius={ average=15, amplitude=6 }, + radius={ average=10, amplitude=4, frequency=8 }, density=1, rarity=0.025, -- this^3*mapblock_volume veins per mapblock localized={ diff --git a/mapgen.lua b/mapgen.lua index 4550d85..fff253b 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -25,6 +25,8 @@ rocksl.register_blob=function(layer,name,param) layer.stats.node[name]=0 end +rocksl.register_vein=function(layer,name,param) + rocksl.layergen=function(layer, minp, maxp, seed) if ( (layer.top.offset+layer.top.scale)>minp.y ) and ( (layer.bot.offset-layer.bot.scale)vein.maxy) then + local vr2=vein.radius.average^2 + local vrm=vein.radius.average+vein.radius.amplitude + local noise_map=minetest.get_perlin_map( + { + seed=-79, + scale=vein.radius.amplitude, + offset=0, octaves=1, persist=0.7, + spread={x=vein.radius.frequency, y=vein.radius.frequency, z=vein.radius.frequency} + },{x=(vrm*2)+1, y=(vrm*2)+1, z=(vrm*2)+1} + ) local iterations_count= (vein.rarity*side_length)^3 - iterations_count=iterations_count+random:next(-1,1) + 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) for iteration=1, iterations_count do local x0=minp.x+ random:next(0,side_length) local y0=minp.y+ random:next(0,side_length) local z0=minp.z+ random:next(0,side_length) - if true or (minetest.get_node({x0,y0,z0}).name==vein.wherein) then - print("vein "..vein.primary.." @ "..x0..","..y0..","..z0) - for x=-vein.radius, vein.radius do - for y=-vein.radius, vein.radius do - for z=-vein.radius, vein.radius do - p={x=x+x0,y=y+y0,z=z+z0} - local nv=noise:get3d(p)*5 - if ((x^2)+(y^2)+(z^2))<((vein.radius+nv)^2) then - minetest.set_node(p, {name=vein.primary}) - end + local noise=noise_map:get3dMap_flat({x=x0-vrm, y=y0-vrm, z=z0-vrm}) + 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) + did_generate=1 + for x=-vrm, vrm do + for y=-vrm, vrm do + for z=-vrm, vrm do + local posc = {x=x+x0,y=y+y0,z=z+z0} + posi = area:index(posc.x, posc.y, posc.z) + local nv=noise[noise_ix] + if ((x^2)+(y^2)+(z^2))<((vein.radius.average+nv)^2) then + --minetest.set_node(posc, {name=vein.primary}) + nodes[posi]=primary_ctx + end + noise_ix=noise_ix+1 end end end else - print("vein "..vein.primary.." bad environmnent") + --print("vein "..vein.primary.." bad environmnent -"..minetest.get_node({x0,y0,z0}).name.."="..nodes[posi]) end end end end - print("end veingen") + if did_generate then + manipulator:set_data(nodes) + --manipulator:calc_lighting() + manipulator:write_to_map() + print("end veingen "..(os.clock()-timebefore)) + else + print("end veingen (nothin generated)") + end end -- ~ Tomas Brod \ No newline at end of file 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 18/18] 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