From ad13c71bf1f84ffbefbcc89e6649081be4aa6c0c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 9 Dec 2019 18:49:59 +0100 Subject: [PATCH] Add partial rotation of levers --- .../REDSTONE/mesecons_walllever/init.lua | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua b/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua index 3c04f72a22..035c32e0ff 100644 --- a/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua @@ -2,6 +2,30 @@ local S = minetest.get_translator("mesecons_wallever") local lever_get_output_rules = mesecon.rules.buttonlike_get +local on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + if node.param2 == 10 then + node.param2 = 13 + minetest.swap_node(pos, node) + return true + elseif node.param2 == 13 then + node.param2 = 10 + minetest.swap_node(pos, node) + return true + elseif node.param2 == 8 then + node.param2 = 15 + minetest.swap_node(pos, node) + return true + elseif node.param2 == 15 then + node.param2 = 8 + minetest.swap_node(pos, node) + return true + end + end + -- TODO: Rotate axis + return false +end + -- LEVER minetest.register_node("mesecons_walllever:wall_lever_off", { drawtype = "mesh", @@ -102,7 +126,7 @@ minetest.register_node("mesecons_walllever:wall_lever_off", { rules = lever_get_output_rules, state = mesecon.state.off }}, - on_rotate = false, + on_rotate = on_rotate, _mcl_blast_resistance = 2.5, _mcl_hardness = 0.5, }) @@ -136,7 +160,7 @@ minetest.register_node("mesecons_walllever:wall_lever_on", { rules = lever_get_output_rules, state = mesecon.state.on }}, - on_rotate = false, + on_rotate = on_rotate, _mcl_blast_resistance = 2.5, _mcl_hardness = 0.5, })