diff options
author | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2018-06-10 17:30:50 +0200 |
---|---|---|
committer | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2018-06-10 17:30:50 +0200 |
commit | 38d10acca24e5a34671a1a71f12923002d06253d (patch) | |
tree | a72aa02902af4dd37bbfa753bdb1ef651e72be88 /advtrains_luaautomation/active_common.lua | |
parent | 3e29cba6af2e19909b6d143cecaec877aaf3a7bd (diff) | |
parent | 8d8e8c1553bc631b8f357005b506bc651de9a138 (diff) | |
download | advtrains-38d10acca24e5a34671a1a71f12923002d06253d.tar.gz advtrains-38d10acca24e5a34671a1a71f12923002d06253d.tar.bz2 advtrains-38d10acca24e5a34671a1a71f12923002d06253d.zip |
Merge branch 'master' of https://github.com/orwell96/advtrains
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 |