diff options
author | cheapie <no-email-for-you@example.com> | 2022-01-02 11:39:13 -0600 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2022-01-02 11:39:13 -0600 |
commit | f82cae841e8ed96c03c7aaefbc26dbff2d811f2b (patch) | |
tree | 06463db19b2f56a2c377f04b9fa48980e4d49a97 | |
parent | 8aaa8f125f9f0e485237b3e5962bab5ca39c9465 (diff) | |
download | mesecons-f82cae841e8ed96c03c7aaefbc26dbff2d811f2b.tar mesecons-f82cae841e8ed96c03c7aaefbc26dbff2d811f2b.tar.gz mesecons-f82cae841e8ed96c03c7aaefbc26dbff2d811f2b.tar.bz2 mesecons-f82cae841e8ed96c03c7aaefbc26dbff2d811f2b.tar.xz mesecons-f82cae841e8ed96c03c7aaefbc26dbff2d811f2b.zip |
Prevent beds from being split by pistons/movestone
Fixes upstream #579 and provides the necessary framework for fixing similar bugs involving other mods.
-rw-r--r-- | mesecons_mvps/init.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/mesecons_mvps/init.lua b/mesecons_mvps/init.lua index a7f2b45..ef4b876 100644 --- a/mesecons_mvps/init.lua +++ b/mesecons_mvps/init.lua @@ -357,3 +357,33 @@ mesecon.register_on_mvps_move(function(moved_nodes) end end end) + +--Some multi-node objects need to be registered as (conditional) stoppers as well in order to prevent them from being separated. +function mesecon.register_mvps_inseparable(node1,node2) + mesecon.register_mvps_stopper(node1,function (node, dir, stack, stackid) + if (stack[stackid + 1] + and stack[stackid + 1].node.name == node2 + and stack[stackid + 1].node.param2 == node.param2) + or (stack[stackid - 1] + and stack[stackid - 1].node.name == node2 + and stack[stackid - 1].node.param2 == node.param2) then + return false + end + return true + end + ) + mesecon.register_mvps_stopper(node2,function (node, dir, stack, stackid) + if (stack[stackid + 1] + and stack[stackid + 1].node.name == node1 + and stack[stackid + 1].node.param2 == node.param2) + or (stack[stackid - 1] + and stack[stackid - 1].node.name == node1 + and stack[stackid - 1].node.param2 == node.param2) then + return false + end + return true + end + ) +end +mesecon.register_mvps_inseparable("beds:bed_bottom","beds:bed_top") +mesecon.register_mvps_inseparable("beds:fancy_bed_bottom","beds:fancy_bed_top") |