diff options
author | orwell96 <orwell@bleipb.de> | 2021-02-17 19:10:40 +0100 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2021-02-17 19:15:20 +0100 |
commit | 1e4156d0a4e42b519ca2f64f4146c7a7faec49a3 (patch) | |
tree | 05e3bf4c32154fe639c9b1b59640cdb053076fca /advtrains_luaautomation/active_common.lua | |
parent | d13a610c2e66b4ac1e585c15022ce43317e6ea4c (diff) | |
download | advtrains-1e4156d0a4e42b519ca2f64f4146c7a7faec49a3.tar.gz advtrains-1e4156d0a4e42b519ca2f64f4146c7a7faec49a3.tar.bz2 advtrains-1e4156d0a4e42b519ca2f64f4146c7a7faec49a3.zip |
LuaATC: Improve error/print logging, log only to subscribed players
Diffstat (limited to 'advtrains_luaautomation/active_common.lua')
-rw-r--r-- | advtrains_luaautomation/active_common.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/advtrains_luaautomation/active_common.lua b/advtrains_luaautomation/active_common.lua index d3985dc..f06eb51 100644 --- a/advtrains_luaautomation/active_common.lua +++ b/advtrains_luaautomation/active_common.lua @@ -109,8 +109,9 @@ function ac.run_in_env(pos, evtdata, customfct_p) atwarn("LuaAutomation component at",ph,": Not an existing environment: "..(nodetbl.env or "<nil>")) return false end + local env = atlatc.envs[nodetbl.env] if not nodetbl.code or nodetbl.code=="" then - atwarn("LuaAutomation component at",ph,": No code to run! (insert -- to suppress warning)") + env:log("warning", "LuaAutomation component at",ph,": No code to run! (insert -- to suppress warning)") return false end @@ -141,14 +142,14 @@ function ac.run_in_env(pos, evtdata, customfct_p) end local datain=nodetbl.data or {} - local succ, dataout = atlatc.envs[nodetbl.env]:execute_code(datain, nodetbl.code, evtdata, customfct) + local succ, dataout = env:execute_code(datain, nodetbl.code, evtdata, customfct) if succ then atlatc.active.nodes[ph].data=atlatc.remove_invalid_data(dataout) else atlatc.active.nodes[ph].err=dataout - atwarn("LuaAutomation ATC interface rail at",ph,": LUA Error:",dataout) + env:log("error", "LuaATC component at",ph,": LUA Error:",dataout) if meta then - meta:set_string("infotext", "LuaAutomation ATC interface rail, ERROR:"..dataout) + meta:set_string("infotext", "LuaATC component, ERROR:"..dataout) end --TODO temporary --if customfct.atc_id then |