diff options
author | Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com> | 2019-06-02 03:17:19 -0400 |
---|---|---|
committer | Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com> | 2019-06-02 03:17:19 -0400 |
commit | 1ae88c7f27d406a2431d552794fba8dc14f12478 (patch) | |
tree | 6186c9ac11f9749aa730b6fe25b8781c37a02579 /ilights/init.lua | |
parent | 2b45a7d33c487758a3ef53318dd779462b414495 (diff) | |
download | dreambuilder_modpack-1ae88c7f27d406a2431d552794fba8dc14f12478.tar dreambuilder_modpack-1ae88c7f27d406a2431d552794fba8dc14f12478.tar.gz dreambuilder_modpack-1ae88c7f27d406a2431d552794fba8dc14f12478.tar.bz2 dreambuilder_modpack-1ae88c7f27d406a2431d552794fba8dc14f12478.tar.xz dreambuilder_modpack-1ae88c7f27d406a2431d552794fba8dc14f12478.zip |
update digistuff, homedecor, ilights, technic, and unified_inventory
Diffstat (limited to 'ilights/init.lua')
-rw-r--r-- | ilights/init.lua | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/ilights/init.lua b/ilights/init.lua index 2b4c396..2716d5c 100644 --- a/ilights/init.lua +++ b/ilights/init.lua @@ -70,6 +70,15 @@ local player_last_clicked = {} local digiline_on_punch +local onoff_tab = { + ["off"] = "off", + ["low"] = "off", + ["med"] = "on", + ["hi"] = "on", + ["max"] = "on", + ["on"] = "on", +} + if minetest.get_modpath("digilines") then local on_digiline_receive_string = function(pos, node, channel, msg) @@ -77,11 +86,17 @@ if minetest.get_modpath("digilines") then local setchan = meta:get_string("channel") if setchan ~= channel then return end - if msg and msg ~= "" and type(msg) == "string" then - if msg == "off" or msg == "on" then + if msg and msg ~= "" then + local n = tonumber(msg) + if n then + msg = (n > 3) and "on" or "off" -- same threshold as in homedecor's lights + end + + local light = onoff_tab[msg] + if light then local basename = string.sub(node.name, 1, string.find(node.name, "_", -5) - 1) - if minetest.registered_nodes[basename.."_"..msg] then - minetest.swap_node(pos, {name = basename.."_"..msg, param2 = node.param2}) + if minetest.registered_nodes[basename.."_"..light] then + minetest.swap_node(pos, {name = basename.."_"..light, param2 = node.param2}) end end end |