mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-12-25 09:50:19 +01:00
Fix active button staying on forever (#355)
This commit is contained in:
parent
564bdc2d9b
commit
36a6419481
@ -4,13 +4,14 @@
|
|||||||
|
|
||||||
mesecon.button_turnoff = function (pos)
|
mesecon.button_turnoff = function (pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node.name=="mesecons_button:button_on" then --has not been dug
|
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.swap_node(pos, {name = "mesecons_button:button_off", param2 = node.param2})
|
||||||
minetest.sound_play("mesecons_button_pop", {pos = pos})
|
minetest.sound_play("mesecons_button_pop", {pos = pos})
|
||||||
local rules = mesecon.rules.buttonlike_get(node)
|
local rules = mesecon.rules.buttonlike_get(node)
|
||||||
mesecon.receptor_off(pos, rules)
|
mesecon.receptor_off(pos, rules)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node("mesecons_button:button_off", {
|
minetest.register_node("mesecons_button:button_off", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
@ -45,7 +46,7 @@ minetest.register_node("mesecons_button:button_off", {
|
|||||||
minetest.swap_node(pos, {name = "mesecons_button:button_on", param2=node.param2})
|
minetest.swap_node(pos, {name = "mesecons_button:button_on", param2=node.param2})
|
||||||
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||||
minetest.sound_play("mesecons_button_push", {pos=pos})
|
minetest.sound_play("mesecons_button_push", {pos=pos})
|
||||||
minetest.after(1, mesecon.button_turnoff, pos)
|
minetest.get_node_timer(pos):start(1)
|
||||||
end,
|
end,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
@ -89,7 +90,8 @@ minetest.register_node("mesecons_button:button_on", {
|
|||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
state = mesecon.state.on,
|
state = mesecon.state.on,
|
||||||
rules = mesecon.rules.buttonlike_get
|
rules = mesecon.rules.buttonlike_get
|
||||||
}}
|
}},
|
||||||
|
on_timer = mesecon.button_turnoff,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
Loading…
Reference in New Issue
Block a user