From 838305401f33400de95c67d030661a8d506eb0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Brada?= Date: Mon, 27 Apr 2015 17:02:59 +0200 Subject: [PATCH] Using lua mapgen to generate layers and minetest to do ores, but I do not like it. --- rocks/ign.lua | 78 +++++++++++++++++++++++++++++++++++++-------- rocks/pegmatite.lua | 2 +- rocks/skarn.lua | 2 +- 3 files changed, 66 insertions(+), 16 deletions(-) diff --git a/rocks/ign.lua b/rocks/ign.lua index 8c948e6..6b7ba7e 100644 --- a/rocks/ign.lua +++ b/rocks/ign.lua @@ -54,20 +54,6 @@ local reg=function(name,param) end rocks.register_igneous_stratus=reg --- add our rocks to stone, under -48 there are no biomes, so randomly choose. - reg( "rocks:basalt", {spread=60, height=40, treshold=0.43, inr={"default:stone"} }) - - minetest.register_ore({ - ore="rocks:granite", wherein="default:stone", - ore_type="scatter", clust_scarcity=3^3, clust_num_ores=6^3, clust_size=6, - height_min=-31000, height_max=-31, - }) - --- continental (granite): diorite and gabbro --- oceanic (basalt): gabbro - reg( "rocks:gabbro", {spread=80, height=60, treshold=0.36, inr={"rocks:granite","rocks:basalt"} }) - reg( "rocks:diorite", {spread=80, height=60, treshold=0.25, inr={"rocks:granite"} }) - -- vein stuff local regv=function(name,param) @@ -103,5 +89,69 @@ rocks.register_vein("default:nyancat",{ } }) +local np_layer = { + offset = 0, octaves = 3, persist = 0.46, + scale = 30, + spread = {x=500, y=500, z=500}, + seed = -5500, +} +local np_intr = { + octaves = 3, persist = 0.46, + scale = 20, + offset = -15, + spread = {x=100, y=100, z=100}, + seed = 3740, +} + +minetest.register_on_generated( function( minp, maxp, seed ) + local t1 = os.clock() + local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") + local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax} + local data = vm:get_data() + + local chunksize = maxp.x - minp.x + 1 + local pmapsize = {x = chunksize, y = chunksize, z = 1} + local pmapminpxz = {x = minp.x, y = minp.z} + local c_stone= minetest.get_content_id("default:stone") + local layers= { + { min=-100, node="rocks:granite" }, + { min=-240, node="rocks:diorite"}, + { node="rocks:gabbro", min=-700}, + } + for k,v in pairs(layers) do + v.ctx=minetest.get_content_id(v.node) + end + local layers_no=#layers + local n_layer= minetest.get_perlin_map(np_layer, pmapsize) : get2dMap_flat(pmapminpxz) + local n_intr= minetest.get_perlin_map(np_intr, pmapsize) : get2dMap_flat(pmapminpxz) + local nixz= 1 + + for z=minp.z, maxp.z do for x=minp.x, maxp.x do + -- loop + for y=minp.y, maxp.y do + local di=area:index(x,y,z) + local yn=y+n_layer[nixz] + local vintr=n_intr[nixz] + if vintr<1 then vintr=1 end + if data[di]==c_stone then + yn=yn*vintr -- vertical intrusion + for li=1, layers_no do + if yn > layers[li].min then + data[di]=layers[li].ctx + break + end + end + end + end + nixz= nixz+1 + end end + + vm:set_data(data) + vm:set_lighting({day=15,night=2}) + minetest.generate_ores(vm) + vm:write_to_map(data) + minetest.log("action", "rocks/layer/ "..math.ceil((os.clock() - t1) * 1000).." ms ") +end) + -- ~ Tomas Brod \ No newline at end of file diff --git a/rocks/pegmatite.lua b/rocks/pegmatite.lua index cb8ac2e..5e79a06 100644 --- a/rocks/pegmatite.lua +++ b/rocks/pegmatite.lua @@ -15,7 +15,7 @@ minetest.register_node( "rocks:pegmatite", { -- pegmatites are only 1 kind rocks.register_vein("rocks:pegmatite",{ - wherein={ "rocks:granite", "default:stone" }, + wherein={ "rocks:granite" }, miny=-160, maxy=20, radius={ average=18, amplitude=0.3, frequency=16 }, density=80, rarity=CommonRarity, diff --git a/rocks/skarn.lua b/rocks/skarn.lua index dfe7ed3..e0081ac 100644 --- a/rocks/skarn.lua +++ b/rocks/skarn.lua @@ -4,7 +4,7 @@ local CommonRarity=40 --too high... should be like 76 local CommonRadius=10 -local CommonWherein={ "rocks:granite", "rocks:limestone", "default:stone" } +local CommonWherein={ "rocks:granite", "rocks:limestone" } minetest.register_node( "rocks:skarn", { description = S("Skarn"),