From 1feae7a1ea35fd8f4f3495d1bf65f8180bb0f720 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 25 Apr 2018 17:14:03 +0200 Subject: Add digiline interface and is_passive function to LuaATC --- advtrains_luaautomation/active_common.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'advtrains_luaautomation/active_common.lua') diff --git a/advtrains_luaautomation/active_common.lua b/advtrains_luaautomation/active_common.lua index 8c910c6..62dc83c 100644 --- a/advtrains_luaautomation/active_common.lua +++ b/advtrains_luaautomation/active_common.lua @@ -111,9 +111,19 @@ function ac.run_in_env(pos, evtdata, customfct_p) end local customfct=customfct_p or {} + -- add interrupt function customfct.interrupt=function(t, imesg) + assertt(t, "number") + assert(t >= 0) atlatc.interrupt.add(t, pos, {type="int", int=true, message=imesg}) end + -- add digiline_send function, if digiline is loaded + if digiline then + customfct.digiline_send=function(channel, msg) + assertt(channel, "string") + digiline:receptor_send(pos, digiline.rules.default, channel, msg) + end + end local datain=nodetbl.data or {} local succ, dataout = atlatc.envs[nodetbl.env]:execute_code(datain, nodetbl.code, evtdata, customfct) @@ -131,4 +141,8 @@ function ac.run_in_env(pos, evtdata, customfct_p) end end +function ac.on_digiline_receive(pos, node, channel, msg) + atlatc.interrupt.add(0, pos, {type="digiline", digiline=true, channel = channel, msg = msg}) +end + atlatc.active=ac -- cgit v1.2.3