From 33a5be054c51dca87f5c0efd24aef3d5bab5ecf1 Mon Sep 17 00:00:00 2001 From: goblin_mode Date: Mon, 28 Oct 2024 21:05:38 +0100 Subject: [PATCH] add aliases for old mesecons pistons --- mods/ITEMS/REDSTONE/mcl_pistons/nodes.lua | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/mods/ITEMS/REDSTONE/mcl_pistons/nodes.lua b/mods/ITEMS/REDSTONE/mcl_pistons/nodes.lua index 5db07a466..b71d79345 100644 --- a/mods/ITEMS/REDSTONE/mcl_pistons/nodes.lua +++ b/mods/ITEMS/REDSTONE/mcl_pistons/nodes.lua @@ -335,3 +335,41 @@ doc.add_entry_alias("nodes", "mcl_pistons:piston_normal_off", "nodes", "mcl_pist doc.add_entry_alias("nodes", "mcl_pistons:piston_normal_off", "nodes", "mcl_pistons:piston_pusher_normal") doc.add_entry_alias("nodes", "mcl_pistons:piston_sticky_off", "nodes", "mcl_pistons:piston_sticky_on") doc.add_entry_alias("nodes", "mcl_pistons:piston_sticky_off", "nodes", "mcl_pistons:piston_pusher_sticky") + +-- convert old mesecons pistons to mcl_pistons +minetest.register_lbm( +{ + label = "update legacy mesecons pistons", + name = "mcl_pistons:replace_legacy_pistons", + nodenames = + { + "mesecons_pistons:piston_normal_off", "mesecons_pistons:piston_up_normal_off", "mesecons_pistons:piston_down_normal_off", + "mesecons_pistons:piston_normal_on", "mesecons_pistons:piston_up_normal_on", "mesecons_pistons:piston_down_normal_on", + "mesecons_pistons:piston_pusher_normal", "mesecons_pistons:piston_up_pusher_normal", "mesecons_pistons:piston_down_pusher_normal", + "mesecons_pistons:piston_sticky_off", "mesecons_pistons:piston_up_sticky_off", "mesecons_pistons:piston_down_sticky_off", + "mesecons_pistons:piston_sticky_on", "mesecons_pistons:piston_up_sticky_on", "mesecons_pistons:piston_down_sticky_on", + "mesecons_pistons:piston_pusher_sticky", "mesecons_pistons:piston_up_pusher_sticky", "mesecons_pistons:piston_down_pusher_sticky", + }, + + action = function(pos, node) + local new_param2 = node.param2 + if string.find(node.name, "up") then + new_param2 = minetest.dir_to_facedir(vector.new(0, -1, 0), true) + elseif string.find(node.name, "down") then + new_param2 = minetest.dir_to_facedir(vector.new(0, 1, 0), true) + end + + local is_sticky = string.find(node.name, "sticky") and true or false + local nodename = "" + + if string.find(node.name, "_on") then + nodename = is_sticky and "mcl_pistons:piston_sticky_on" or "mcl_pistons:piston_normal_on" + elseif string.find(node.name, "_off") then + nodename = is_sticky and "mcl_pistons:piston_sticky_off" or "mcl_pistons:piston_normal_off" + elseif string.find(node.name, "_pusher") then + nodename = is_sticky and "mcl_pistons:piston_pusher_sticky" or "mcl_pistons:piston_pusher_normal" + end + + minetest.set_node(pos, {name = nodename, param2 = new_param2}) + end +})