aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation/environment.lua
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains_luaautomation/environment.lua')
-rw-r--r--advtrains_luaautomation/environment.lua18
1 files changed, 16 insertions, 2 deletions
diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua
index d85bedc..b54d45c 100644
--- a/advtrains_luaautomation/environment.lua
+++ b/advtrains_luaautomation/environment.lua
@@ -153,6 +153,12 @@ local static_env = {
local pos=atlatc.pcnaming.resolve_pos(parpos, "interrupt_pos")
atlatc.interrupt.add(0, pos, {type="ext_int", ext_int=true, message=imesg})
end,
+ train_parts = function(train_id)
+ if not train_id then return false end
+ local train = advtrains.trains[train_id]
+ if not train then return false end
+ return table.copy(train.trainparts or {})
+ end,
-- sends an atc command to train regardless of where it is in the world
atc_send_to_train = function(train_id, command)
assertt(command, "string")
@@ -164,6 +170,9 @@ local static_env = {
return false
end
end,
+ get_slowdown = function()
+ return advtrains.global_slowdown
+ end
}
-- If interlocking is present, enable route setting functions
@@ -221,7 +230,7 @@ if advtrains.interlocking then
end
static_env.set_aspect = function(signal, asp)
local pos = atlatc.pcnaming.resolve_pos(signal)
- return advtrains.interlocking.signal_set_aspect(pos)
+ return advtrains.interlocking.signal_set_aspect(pos,asp)
end
--section_occupancy()
@@ -230,7 +239,7 @@ if advtrains.interlocking then
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)
+ return (response.trains and table.copy(response.trains)) or {}
end
end
@@ -259,6 +268,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