forked from VoxeLibre/VoxeLibre
Fix active buttons staying on after restart
This commit is contained in:
parent
fb8c5300cd
commit
64f7e0a076
|
@ -98,20 +98,11 @@ mesecon.register_button = function(basename, description, texture, recipeitem, s
|
||||||
on_place = on_button_place,
|
on_place = on_button_place,
|
||||||
node_placement_prediction = "",
|
node_placement_prediction = "",
|
||||||
on_rightclick = function (pos, node)
|
on_rightclick = function (pos, node)
|
||||||
minetest.swap_node(pos, {name="mesecons_button:button_"..basename.."_on", param2=node.param2})
|
minetest.set_node(pos, {name="mesecons_button:button_"..basename.."_on", param2=node.param2})
|
||||||
mesecon.receptor_on(pos, button_get_output_rules(node))
|
mesecon.receptor_on(pos, button_get_output_rules(node))
|
||||||
minetest.sound_play("mesecons_button_push", {pos=pos})
|
minetest.sound_play("mesecons_button_push", {pos=pos})
|
||||||
local button_turnoff = function(a)
|
local timer = minetest.get_node_timer(pos)
|
||||||
local pos = a.pos
|
timer:start(button_timer)
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
local basename = a.basename
|
|
||||||
if node.name=="mesecons_button:button_"..basename.."_on" then --has not been dug
|
|
||||||
minetest.swap_node(pos, {name="mesecons_button:button_"..basename.."_off",param2=node.param2})
|
|
||||||
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
|
||||||
mesecon.receptor_off(pos, button_get_output_rules(node))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
minetest.after(button_timer, button_turnoff, {pos=pos, basename=basename})
|
|
||||||
end,
|
end,
|
||||||
sounds = sounds,
|
sounds = sounds,
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
|
@ -143,6 +134,14 @@ mesecon.register_button = function(basename, description, texture, recipeitem, s
|
||||||
state = mesecon.state.on,
|
state = mesecon.state.on,
|
||||||
rules = button_get_output_rules
|
rules = button_get_output_rules
|
||||||
}},
|
}},
|
||||||
|
on_timer = function(pos, elapsed)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
if node.name=="mesecons_button:button_"..basename.."_on" then --has not been dug
|
||||||
|
minetest.set_node(pos, {name="mesecons_button:button_"..basename.."_off",param2=node.param2})
|
||||||
|
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
||||||
|
mesecon.receptor_off(pos, button_get_output_rules(node))
|
||||||
|
end
|
||||||
|
end,
|
||||||
_mcl_blast_resistance = 2.5,
|
_mcl_blast_resistance = 2.5,
|
||||||
_mcl_hardness = 0.5,
|
_mcl_hardness = 0.5,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue