From 76507025d96749e1e491df4a1d0dd93cd950b9f8 Mon Sep 17 00:00:00 2001 From: Michieal Date: Mon, 6 Feb 2023 16:51:48 -0500 Subject: [PATCH] Cleaned up the global function to match the current ABM. --- mods/ITEMS/mcl_bamboo/globals.lua | 43 ++++++++++++++----------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/mods/ITEMS/mcl_bamboo/globals.lua b/mods/ITEMS/mcl_bamboo/globals.lua index 168684e06..54c1c85ee 100644 --- a/mods/ITEMS/mcl_bamboo/globals.lua +++ b/mods/ITEMS/mcl_bamboo/globals.lua @@ -67,33 +67,28 @@ end local BAMBOO_ENDCAP_NAME = "mcl_bamboo:bamboo_endcap" ---[[ For when I learn more about the pistons... +-- For when I learn more about the pistons... function mcl_bamboo.break_orphaned(pos) - local node_below = minetest.get_node(vector.offset(pos, 0, -1, 0)) - local node_name = node_below.name + local node_below = minetest.get_node(vector.offset(pos, 0, -1, 0)) + local node_name = node_below.name - -- prevent accidental calling on non-bamboo nodes. - if mcl_bamboo.is_bamboo(minetest.get_node(pos).name) == false then - return - end - - if mcl_bamboo.is_dirt(node_name) == false and mcl_bamboo.is_bamboo(node_name) == false then - -- dig the node. - if not minetest.dig_node(pos) then - -- If dig_node fails, to prevent the bamboo from hanging in the air, manually remove it. - minetest.remove_node(pos) -- if that fails, remove the node - local istack = ItemStack("mcl_bamboo:bamboo") - local sound_params = { - pos = pos, - gain = 1.0, -- default - max_hear_distance = 10, -- default, uses a Euclidean metric - } - - minetest.remove_node(pos) - minetest.sound_play(mcl_sounds.node_sound_wood_defaults().dug, sound_params, true) - minetest.add_item(pos, istack) + -- short circuit checks. + if mcl_bamboo.is_dirt(node_name) or mcl_bamboo.is_bamboo(node_name) or mcl_bamboo.is_bamboo(minetest.get_node(pos).name) == false then + return end - end + + -- dig the node. + minetest.remove_node(pos) -- if that fails, remove the node + local istack = ItemStack("mcl_bamboo:bamboo") + local sound_params = { + pos = pos, + gain = 1.0, -- default + max_hear_distance = 10, -- default, uses a Euclidean metric + } + + minetest.remove_node(pos) + minetest.sound_play(mcl_sounds.node_sound_wood_defaults().dug, sound_params, true) + minetest.add_item(pos, istack) end --]]