From b28f1314da7bcfbac985f90e2ba5a7e478e81e75 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Sat, 15 Jun 2019 06:47:33 -0400 Subject: [PATCH] add aliases for rope lights (on/14, off/0) make right-click handler work properly for plain "on"/"off" items --- homedecor_lighting/init.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/homedecor_lighting/init.lua b/homedecor_lighting/init.lua index 72ac8e42..c40fff2a 100644 --- a/homedecor_lighting/init.lua +++ b/homedecor_lighting/init.lua @@ -184,10 +184,14 @@ function homedecor.toggle_light(pos, node, clicker, itemstack, pointed_thing) local level = string.sub(node.name, sep + 1) local n = tonumber(level) or 0 - if level == "off" or n < 4 then - newsuff = "_14" - else + if level == "on" then + newsuff = "_off" + elseif level == "off" then + newsuff = "_on" + elseif n > 3 then newsuff = "_0" + else + newsuff = "_14" end minetest.swap_node(pos, {name = string.sub(node.name, 1, sep - 1)..newsuff, param2 = node.param2}) @@ -1848,6 +1852,11 @@ minetest.register_alias("torch_wall", "homedecor:torch_ minetest.register_alias("homedecor:plasma_ball", "homedecor:plasma_ball_on") minetest.register_alias("homedecor:wall_lamp", "homedecor:wall_lamp_on") +minetest.register_alias("homedecor:rope_light_on_floor_0", "homedecor:rope_light_on_floor_off") +minetest.register_alias("homedecor:rope_light_on_floor_14", "homedecor:rope_light_on_floor_on") + +minetest.register_alias("homedecor:rope_light_on_ceiling_0", "homedecor:rope_light_on_ceiling_off") +minetest.register_alias("homedecor:rope_light_on_ceiling_14", "homedecor:rope_light_on_ceiling_on") for name, level in pairs(word_to_bright) do minetest.register_alias("homedecor:glowlight_half_"..name, "homedecor:glowlight_half_"..level)