From 04c78373f1db0b011557b92cd6fb58268cbeefe4 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 17 Feb 2021 19:45:52 +0100 Subject: LuaATC: add interrupt_safe() and clear_interrupts(), fix queue mainloop --- advtrains_luaautomation/active_common.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'advtrains_luaautomation/active_common.lua') diff --git a/advtrains_luaautomation/active_common.lua b/advtrains_luaautomation/active_common.lua index f06eb51..d168bad 100644 --- a/advtrains_luaautomation/active_common.lua +++ b/advtrains_luaautomation/active_common.lua @@ -122,6 +122,18 @@ function ac.run_in_env(pos, evtdata, customfct_p) assert(t >= 0) atlatc.interrupt.add(t, pos, {type="int", int=true, message=imesg, msg=imesg}) --Compatiblity "message" field. end + customfct.interrupt_safe=function(t, imesg) + assertt(t, "number") + assert(t >= 0) + if atlatc.interrupt.has_at_pos(pos) then + return false + end + atlatc.interrupt.add(t, pos, {type="int", int=true, message=imesg, msg=imesg}) --Compatiblity "message" field. + return true + end + customfct.clear_interrupts=function() + atlatc.interrupt.clear_ints_at_pos(pos) + end -- add digiline_send function, if digiline is loaded if minetest.global_exists("digiline") then customfct.digiline_send=function(channel, msg) -- cgit v1.2.3