From 81b2b0898b39a636c1f7a7ec77aa5fd60e9e1f6a Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Tue, 6 Apr 2021 03:32:04 -0400 Subject: [PATCH 1/3] don't use a function to pick random dry grasses just use `biome_lib`'s random-choice table feature (it was only there to let the mod replace junglegrass, but that's pointless when junglegrass doesn't tend to spawn in the same areas) --- dryplants/moregrass.lua | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/dryplants/moregrass.lua b/dryplants/moregrass.lua index b8d5f82..46768e7 100644 --- a/dryplants/moregrass.lua +++ b/dryplants/moregrass.lua @@ -7,26 +7,24 @@ -- Looked at code from: default ----------------------------------------------------------------------------------------------- -abstract_dryplants.grow_grass = function(pos) - local right_here = {x=pos.x, y=pos.y+1, z=pos.z} - local grass_size = math.random(1,5) - if minetest.get_node(right_here).name == "air" -- instead of check_air = true, - or minetest.get_node(right_here).name == "default:junglegrass" then - minetest.swap_node(right_here, {name="default:grass_"..grass_size}) - end -end - -biome_lib:register_generate_plant({ - surface = { - "default:dirt_with_grass", - "stoneage:grass_with_silex", - "sumpf:peat", - "sumpf:sumpf" +biome_lib:register_generate_plant( + { + surface = { + "default:dirt_with_grass", + "stoneage:grass_with_silex", + "sumpf:peat", + "sumpf:sumpf" + }, + max_count = TALL_GRASS_PER_MAPBLOCK, + rarity = 101 - TALL_GRASS_RARITY, + min_elevation = 1, -- above sea level + plantlife_limit = -0.9, + check_air = true, }, - max_count = TALL_GRASS_PER_MAPBLOCK, - rarity = 101 - TALL_GRASS_RARITY, - min_elevation = 1, -- above sea level - plantlife_limit = -0.9, - }, - abstract_dryplants.grow_grass + { "default:grass_1", + "default:grass_2", + "default:grass_3", + "default:grass_4", + "default:grass_5" + } ) From 4876fc12658b3159d0770dc5030bd673ed162491 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Tue, 6 Apr 2021 04:04:08 -0400 Subject: [PATCH 2/3] let biome_lib place pebbles instead of using custom mapgen code --- cavestuff/init.lua | 2 ++ cavestuff/mapgen.lua | 77 ++++++++++++++++---------------------------- cavestuff/mod.conf | 2 +- 3 files changed, 31 insertions(+), 50 deletions(-) diff --git a/cavestuff/init.lua b/cavestuff/init.lua index e3dba36..3f46ea9 100644 --- a/cavestuff/init.lua +++ b/cavestuff/init.lua @@ -7,6 +7,8 @@ local mname = "cavestuff" -- support for i18n local S = minetest.get_translator("cavestuff") +cavestuff = {} + dofile(minetest.get_modpath("cavestuff").."/nodes.lua") dofile(minetest.get_modpath("cavestuff").."/mapgen.lua") diff --git a/cavestuff/mapgen.lua b/cavestuff/mapgen.lua index 3be9f31..97917e4 100644 --- a/cavestuff/mapgen.lua +++ b/cavestuff/mapgen.lua @@ -1,52 +1,31 @@ --Map Generation Stuff -minetest.register_on_generated(function(minp, maxp, seed) - if maxp.y >= 2 and minp.y <= 0 then - -- Generate pebbles - local perlin1 = minetest.get_perlin(329, 3, 0.6, 100) - -- Assume X and Z lengths are equal - local divlen = 16 - local divs = (maxp.x-minp.x)/divlen+1; - for divx=0,divs-1 do - for divz=0,divs-1 do - local x0 = minp.x + math.floor((divx+0)*divlen) - local z0 = minp.z + math.floor((divz+0)*divlen) - local x1 = minp.x + math.floor((divx+1)*divlen) - local z1 = minp.z + math.floor((divz+1)*divlen) - -- Determine pebble amount from perlin noise - local pebble_amount = math.floor(perlin1:get2d({x=x0, y=z0}) ^ 2 * 2) - -- Find random positions for pebbles based on this random - local pr = PseudoRandom(seed+1) - for i=0,pebble_amount do - local x = pr:next(x0, x1) - local z = pr:next(z0, z1) - -- Find ground level (0...15) - local ground_y = nil - for y=30,0,-1 do - if minetest.get_node({x=x,y=y,z=z}).name ~= "air" then - ground_y = y - break - end - end +biome_lib:register_generate_plant( + { + surface = { "default:dirt_with_grass" }, + max_count = 50, + rarity = 0, + plantlife_limit = -1, + check_air = true, + random_facedir = {0, 3} + }, + { + "cavestuff:pebble_1", + "cavestuff:pebble_2" + } +) - if ground_y then - local p = {x=x,y=ground_y+1,z=z} - local nn = minetest.get_node(p).name - -- Check if the node can be replaced - if minetest.registered_nodes[nn] and - minetest.registered_nodes[nn].buildable_to then - nn = minetest.get_node({x=x,y=ground_y,z=z}).name - -- If desert sand, add dry shrub - if nn == "default:dirt_with_grass" then - minetest.swap_node(p,{name="cavestuff:pebble_"..pr:next(1,2), param2=math.random(0,3)}) - elseif nn == "default:desert_sand" then - minetest.swap_node(p,{name="cavestuff:desert_pebble_"..pr:next(1,2), param2=math.random(0,3)}) - end - end - end - - end - end - end - end -end) +biome_lib:register_generate_plant( + { + surface = { "default:desert_sand" }, + max_count = 50, + rarity = 0, + plantlife_limit = -1, + check_air = true, + random_facedir = {0, 3} + }, + { + "cavestuff:desert_pebble_1", + "cavestuff:desert_pebble_2" + } +) diff --git a/cavestuff/mod.conf b/cavestuff/mod.conf index b021c9e..55cdcab 100644 --- a/cavestuff/mod.conf +++ b/cavestuff/mod.conf @@ -1,2 +1,2 @@ name = cavestuff -depends = default +depends = default,biome_lib From 70df655a42692b179f25825b55b3d277f17e30e5 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Tue, 6 Apr 2021 04:08:47 -0400 Subject: [PATCH 3/3] allow pebbles to spawn on a few more surface types --- cavestuff/mapgen.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cavestuff/mapgen.lua b/cavestuff/mapgen.lua index 97917e4..5c8aae3 100644 --- a/cavestuff/mapgen.lua +++ b/cavestuff/mapgen.lua @@ -2,7 +2,12 @@ biome_lib:register_generate_plant( { - surface = { "default:dirt_with_grass" }, + surface = { + "default:dirt_with_grass", + "default:gravel", + "default:stone", + "default:permafrost_with_stones" + }, max_count = 50, rarity = 0, plantlife_limit = -1, @@ -17,7 +22,10 @@ biome_lib:register_generate_plant( biome_lib:register_generate_plant( { - surface = { "default:desert_sand" }, + surface = { + "default:desert_sand", + "default:desert_stone" + }, max_count = 50, rarity = 0, plantlife_limit = -1,