aboutsummaryrefslogtreecommitdiff
path: root/advtrains/advtrains_luaautomation/active_common.lua
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2017-02-02 21:14:20 +0100
committerorwell96 <mono96.mml@gmail.com>2017-02-02 21:14:20 +0100
commit948482a99e4aae4d51ff97879432140645959f46 (patch)
tree7920fcec8ee918e56e3c67acbf1b7ce4335bc740 /advtrains/advtrains_luaautomation/active_common.lua
parentb19033b224f4f8ec33f10ba40327f1d811c04fbb (diff)
downloadadvtrains-948482a99e4aae4d51ff97879432140645959f46.tar.gz
advtrains-948482a99e4aae4d51ff97879432140645959f46.tar.bz2
advtrains-948482a99e4aae4d51ff97879432140645959f46.zip
LuaAutomation: Add interrupt to the ingame API and implement initialization code handling and env management
Diffstat (limited to 'advtrains/advtrains_luaautomation/active_common.lua')
-rw-r--r--advtrains/advtrains_luaautomation/active_common.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/advtrains/advtrains_luaautomation/active_common.lua b/advtrains/advtrains_luaautomation/active_common.lua
index b94a260..474838e 100644
--- a/advtrains/advtrains_luaautomation/active_common.lua
+++ b/advtrains/advtrains_luaautomation/active_common.lua
@@ -84,7 +84,7 @@ function ac.on_receive_fields(pos, formname, fields, player)
end
end
-function ac.run_in_env(pos, evtdata, customfct)
+function ac.run_in_env(pos, evtdata, customfct_p)
local ph=minetest.hash_node_position(pos)
local nodetbl = ac.nodes[ph] or {}
@@ -100,6 +100,11 @@ function ac.run_in_env(pos, evtdata, customfct)
return false, "No code to run!"
end
+ local customfct=customfct_p or {}
+ customfct.interrupt=function(t, imesg)
+ atlatc.interrupt.add(t, pos, {type="int", int=true, message=imesg})
+ end
+
local datain=nodetbl.data or {}
local succ, dataout = atlatc.envs[nodetbl.env]:execute_code(datain, nodetbl.code, evtdata, customfct)
if succ then