1
0
Fork 0

Add 1 sec deactivation delay to pplates

This commit is contained in:
parent ba292aeb5d
commit d8c16b1f31
1 changed files with 14 additions and 3 deletions

View File

@ -84,12 +84,23 @@ local function pp_on_timer(pos, elapsed)
obj_touching_plate_pos(obj, pos) obj_touching_plate_pos(obj, pos)
then then
disable = false disable = false
minetest.get_meta(pos):set_string("deact_time", "")
break break
end end
end end
if disable then if disable then
minetest.set_node(pos, {name = basename .. "_off"}) local meta = minetest.get_meta(pos)
mesecon.receptor_off(pos, mesecon.rules.pplate) local deact_time = meta:get_float("deact_time")
local current_time = minetest.get_us_time()
if deact_time == 0 then
deact_time = current_time + 1 * 1000 * 1000
meta:set_float("deact_time", deact_time)
end
if deact_time <= current_time then
minetest.set_node(pos, { name = basename .. "_off" })
mesecon.receptor_off(pos, mesecon.rules.pplate)
meta:set_string("deact_time", "")
end
end end
elseif node.name == basename .. "_off" then elseif node.name == basename .. "_off" then
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
@ -97,7 +108,7 @@ local function pp_on_timer(pos, elapsed)
obj_does_activate(obj, activated_by) and obj_does_activate(obj, activated_by) and
obj_touching_plate_pos(obj, pos) obj_touching_plate_pos(obj, pos)
then then
minetest.set_node(pos, {name = basename .. "_on"}) minetest.set_node(pos, { name = basename .. "_on" })
mesecon.receptor_on(pos, mesecon.rules.pplate) mesecon.receptor_on(pos, mesecon.rules.pplate)
break break
end end