From e7d11b3c381335e0dab3ac0cc3ac898ca6b9a4a5 Mon Sep 17 00:00:00 2001 From: binarycat Date: Sat, 16 Dec 2023 16:33:36 -0500 Subject: [PATCH 1/3] fix issue 645 --- mesecons_pistons/init.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 3d75b35..9fa26c5 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -84,7 +84,16 @@ local piston_on = function(pos, node) local pistonspec = get_pistonspec(node.name, "offname") local dir = vector.multiply(minetest.facedir_to_dir(node.param2), -1) local pusher_pos = vector.add(pos, dir) + local behind_pos = vector.subtract(pos, dir) local meta = minetest.get_meta(pos) + -- NOTE: this gets calculated twice, but fixing this would mean changing the public api. + local stack = mesecon.mvps_get_stack(pusher_pos, dir, max_push, meta:get_string("owner")) + for _, n in ipairs(stack) do + -- fix issue 645 + if vector.equals(n.pos, behind_pos) then + return + end + end local success, stack, oldstack = mesecon.mvps_push(pusher_pos, dir, max_push, meta:get_string("owner")) if not success then if stack == "protected" then From c9f391579257754c72931d2c196ae1b4a208a33f Mon Sep 17 00:00:00 2001 From: binarycat Date: Sat, 16 Dec 2023 17:02:39 -0500 Subject: [PATCH 2/3] fix crash caused by missing nil check --- mesecons_pistons/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 9fa26c5..c6273a5 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -88,7 +88,7 @@ local piston_on = function(pos, node) local meta = minetest.get_meta(pos) -- NOTE: this gets calculated twice, but fixing this would mean changing the public api. local stack = mesecon.mvps_get_stack(pusher_pos, dir, max_push, meta:get_string("owner")) - for _, n in ipairs(stack) do + for _, n in ipairs(stack or {}) do -- fix issue 645 if vector.equals(n.pos, behind_pos) then return From 5d582930847e17df38e976348b88f6d597ca9d22 Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 19 Dec 2023 15:05:46 -0500 Subject: [PATCH 3/3] rename variable to satisfy linter --- mesecons_pistons/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index c6273a5..d38f2fa 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -87,8 +87,8 @@ local piston_on = function(pos, node) local behind_pos = vector.subtract(pos, dir) local meta = minetest.get_meta(pos) -- NOTE: this gets calculated twice, but fixing this would mean changing the public api. - local stack = mesecon.mvps_get_stack(pusher_pos, dir, max_push, meta:get_string("owner")) - for _, n in ipairs(stack or {}) do + local stack_preview = mesecon.mvps_get_stack(pusher_pos, dir, max_push, meta:get_string("owner")) + for _, n in ipairs(stack_preview or {}) do -- fix issue 645 if vector.equals(n.pos, behind_pos) then return