diff options
author | orwell96 <orwell@bleipb.de> | 2018-04-25 17:14:03 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2018-04-25 17:14:03 +0200 |
commit | 1feae7a1ea35fd8f4f3495d1bf65f8180bb0f720 (patch) | |
tree | c4119c0cee9d2aaa0d6daf462391ea519e8345d1 /advtrains_luaautomation/active_common.lua | |
parent | 8b576357ef1d2346e9af112e115ac92a5f4d222d (diff) | |
download | advtrains-1feae7a1ea35fd8f4f3495d1bf65f8180bb0f720.tar.gz advtrains-1feae7a1ea35fd8f4f3495d1bf65f8180bb0f720.tar.bz2 advtrains-1feae7a1ea35fd8f4f3495d1bf65f8180bb0f720.zip |
Add digiline interface and is_passive function to LuaATC
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 |