From 87a88a88a6e581621bb9cfa55c2fdbec83d97507 Mon Sep 17 00:00:00 2001 From: trans_soup <> Date: Thu, 19 Oct 2023 15:52:01 +0200 Subject: [PATCH] fix sapling growth replacing certain nodes. saplings can now replace alive leaves when growing (and other nodes can easily be added in the future). previously, instead of saplings, it was accidentally the case that alive leaves growth worked like this when growing out of sapling, instead of actual sapling growth. --- mods/bg_tree/grow_sapling.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mods/bg_tree/grow_sapling.lua b/mods/bg_tree/grow_sapling.lua index ff32078..a0bd194 100644 --- a/mods/bg_tree/grow_sapling.lua +++ b/mods/bg_tree/grow_sapling.lua @@ -38,6 +38,9 @@ end ]]-- local sapling_grow_cost = 2000 +local sapling_can_replace = { + modname .. ":leaves_alive", +} blockgame.register_increasing_abm({ id = modname .. ":grow_sapling", @@ -58,7 +61,8 @@ blockgame.register_increasing_abm({ if not supports_sapling(below_name) then return false end local above = pos + blockgame.vector.dirs.up - if minetest.get_node(above).name ~= "air" then return false end + local above_name = minetest.get_node(above).name + if above_name ~= "air" and not blockgame.item_matches(above_name, sapling_can_replace) then return false end return true end, @@ -87,7 +91,7 @@ blockgame.register_increasing_abm({ -- grow out leaves to the sides. local sides = blockgame.vector.get_sides_of(above) for _, side in pairs(sides) do - blockgame.attempt_place(side, {name = leaves_growing}, {modname .. ":leaves_alive"}) + blockgame.attempt_place(side, {name = leaves_growing}) end end, })