diff options
Diffstat (limited to 'advtrains_luaautomation/environment.lua')
-rw-r--r-- | advtrains_luaautomation/environment.lua | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua index 63aa68d..6df5248 100644 --- a/advtrains_luaautomation/environment.lua +++ b/advtrains_luaautomation/environment.lua @@ -150,7 +150,7 @@ local static_env = { --interrupts are handled per node, position unknown. (same goes for digilines) --however external interrupts can be set here. interrupt_pos = function(parpos, imesg) - local pos=atlatc.pcnaming.resolve_pos(parpos) + local pos=atlatc.pcnaming.resolve_pos(parpos, "interrupt_pos") atlatc.interrupt.add(0, pos, {type="ext_int", ext_int=true, message=imesg}) end, -- sends an atc command to train regardless of where it is in the world @@ -164,6 +164,9 @@ local static_env = { return false end end, + get_slowdown = function() + return advtrains.global_slowdown + end } -- If interlocking is present, enable route setting functions @@ -223,6 +226,15 @@ if advtrains.interlocking then local pos = atlatc.pcnaming.resolve_pos(signal) return advtrains.interlocking.signal_set_aspect(pos) end + + --section_occupancy() + static_env.section_occupancy = function(ts_id) + if not ts_id then return nil end + ts_id = tostring(ts_id) + local response = advtrains.interlocking.db.get_ts(ts_id) + if not response then return false end + return table.copy(response.trains) + end end -- Lines-specific: @@ -250,6 +262,11 @@ if advtrains.lines then } end + +atlatc.register_function = function (name, f) + static_env[name] = f +end + for _, name in pairs(safe_globals) do static_env[name] = _G[name] end |