diff options
Diffstat (limited to 'advtrains_luaautomation/active_common.lua')
-rw-r--r-- | advtrains_luaautomation/active_common.lua | 14 |
1 files changed, 14 insertions, 0 deletions
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 |