From 948482a99e4aae4d51ff97879432140645959f46 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Thu, 2 Feb 2017 21:14:20 +0100 Subject: LuaAutomation: Add interrupt to the ingame API and implement initialization code handling and env management --- advtrains/advtrains_luaautomation/active_common.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'advtrains/advtrains_luaautomation/active_common.lua') 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 -- cgit v1.2.3