From ffdc7cd035e0751450405913fa99517696931302 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Thu, 21 Mar 2024 05:57:23 -0400 Subject: [PATCH] Consider mapgen v7. Add max height. * set a maximun height and use the parameters on mapgen v7 from poikilos, seems oldcoder already does that! this was taken from old fork from commit https://github.com/Poikilos/tsm_pyramids/commit/e970ff7955ffbf65e5a53805a66bc6af681a9b52 * the commit only takes the max height part.. the node detection suggestion was omited (few 3 lines around sand_cnt_max_id check) cos is already added on the previous function `select_pyramid_type(min, max)` --- init.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 2720e7a..b759ec3 100644 --- a/init.lua +++ b/init.lua @@ -7,7 +7,9 @@ local PYRA_Wm = PYRA_W - 1 -- Half of (Pyramid width minus 1) local PYRA_Wh = PYRA_Wm / 2 -- Minimum spawn height -local PYRA_MIN_Y = 3 +local PYRA_MIN_Y = 1 +-- Maximun spawn height +local PYRA_MAX_Y = 1000 tsm_pyramids = {} @@ -240,9 +242,12 @@ local function make(pos, brick, sandstone, stone, sand, ptype, room_id) return ok, msg end -local perl1 = {SEED1 = 9130, OCTA1 = 3, PERS1 = 0.5, SCAL1 = 250} -- Values should match minetest mapgen V6 desert noise. +local perl1 local perlin1 -- perlin noise buffer +-- if mg v6 set this {SEED1 = 9130, OCTA1 = 3, PERS1 = 0.5, SCAL1 = 250} -- Values should match minetest mapgen V6 desert noise. +perl1 = { SEED1 = 9130, OCTA1 = 1, PERS1 = 0.5, SCAL1 = 25 } -- Values should match minetest mapgen V7 desert noise. + local function hlp_fnct(pos, name) local n = minetest.get_node_or_nil(pos) if n and n.name and n.name == name then @@ -314,7 +319,7 @@ end -- Attempt to generate a pyramid in the generated area. -- Up to one pyramid per mapchunk. minetest.register_on_generated(function(minp, maxp, seed) - if maxp.y < PYRA_MIN_Y then return end + if maxp.y < PYRA_MIN_Y or maxp.y > PYRA_MAX_Y then return end -- TODO: Use Minetests pseudo-random tools math.randomseed(seed) @@ -348,8 +353,8 @@ minetest.register_on_generated(function(minp, maxp, seed) minetest.log("verbose", "[tsm_pyramids] Pyramid not placed, no suitable surface. minp="..minetest.pos_to_string(minp)) return end - if p2.y < PYRA_MIN_Y then - minetest.log("info", "[tsm_pyramids] Pyramid not placed, too deep. p2="..minetest.pos_to_string(p2)) + if p2.y < PYRA_MIN_Y or p2.y > PYRA_MAX_Y then + minetest.log("info", "[tsm_pyramids] Pyramid not placed, too deep or too high. p2="..minetest.pos_to_string(p2)) return end -- Now sink the pyramid until each corner of it is no longer floating in mid-air