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.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua
index 6df5248..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")
@@ -224,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()
@@ -233,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