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
local meta = minetest.get_meta(pos)
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" }) minetest.set_node(pos, { name = basename .. "_off" })
mesecon.receptor_off(pos, mesecon.rules.pplate) 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