summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDS <vorunbekannt75@web.de>2017-09-03 20:27:31 +0200
committerVitaliy <silverunicorn2011@yandex.ru>2017-09-03 21:27:31 +0300
commit36a6419481599c5b5ae2b43697722108fbc1d63d (patch)
tree8e23539e3cef8ba563deefad8f1318bb93d4cbea
parent564bdc2d9b0f265b4286b3caaf8a9059953ce08b (diff)
downloadmesecons-36a6419481599c5b5ae2b43697722108fbc1d63d.tar
mesecons-36a6419481599c5b5ae2b43697722108fbc1d63d.tar.gz
mesecons-36a6419481599c5b5ae2b43697722108fbc1d63d.tar.bz2
mesecons-36a6419481599c5b5ae2b43697722108fbc1d63d.tar.xz
mesecons-36a6419481599c5b5ae2b43697722108fbc1d63d.zip
Fix active button staying on forever (#355)
-rw-r--r--mesecons_button/init.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/mesecons_button/init.lua b/mesecons_button/init.lua
index 11c328c..c67c149 100644
--- a/mesecons_button/init.lua
+++ b/mesecons_button/init.lua
@@ -4,12 +4,13 @@
mesecon.button_turnoff = function (pos)
local node = minetest.get_node(pos)
- if node.name=="mesecons_button:button_on" then --has not been dug
- minetest.swap_node(pos, {name = "mesecons_button:button_off", param2=node.param2})
- minetest.sound_play("mesecons_button_pop", {pos=pos})
- local rules = mesecon.rules.buttonlike_get(node)
- mesecon.receptor_off(pos, rules)
+ if node.name ~= "mesecons_button:button_on" then -- has been dug
+ return
end
+ minetest.swap_node(pos, {name = "mesecons_button:button_off", param2 = node.param2})
+ minetest.sound_play("mesecons_button_pop", {pos = pos})
+ local rules = mesecon.rules.buttonlike_get(node)
+ mesecon.receptor_off(pos, rules)
end
minetest.register_node("mesecons_button:button_off", {
@@ -45,7 +46,7 @@ minetest.register_node("mesecons_button:button_off", {
minetest.swap_node(pos, {name = "mesecons_button:button_on", param2=node.param2})
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
minetest.sound_play("mesecons_button_push", {pos=pos})
- minetest.after(1, mesecon.button_turnoff, pos)
+ minetest.get_node_timer(pos):start(1)
end,
sounds = default.node_sound_stone_defaults(),
mesecons = {receptor = {
@@ -89,7 +90,8 @@ minetest.register_node("mesecons_button:button_on", {
mesecons = {receptor = {
state = mesecon.state.on,
rules = mesecon.rules.buttonlike_get
- }}
+ }},
+ on_timer = mesecon.button_turnoff,
})
minetest.register_craft({