aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation/environment.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2021-03-02 19:51:56 +0100
committerorwell96 <orwell@bleipb.de>2021-03-02 19:51:56 +0100
commit6135f8a23b4f507870dab481f4db466e6be0ac7d (patch)
tree29ea2d7912bba4e08c0dcc1c6da85712b45a2962 /advtrains_luaautomation/environment.lua
parentdb9e4429d789b5217a969de34ecd429c385c380b (diff)
downloadadvtrains-6135f8a23b4f507870dab481f4db466e6be0ac7d.tar.gz
advtrains-6135f8a23b4f507870dab481f4db466e6be0ac7d.tar.bz2
advtrains-6135f8a23b4f507870dab481f4db466e6be0ac7d.zip
LuaATC: add sending atc command to train by ID, and getters for in/out text (solves #124 and #166)
Diffstat (limited to 'advtrains_luaautomation/environment.lua')
-rw-r--r--advtrains_luaautomation/environment.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua
index 9ef320c..63aa68d 100644
--- a/advtrains_luaautomation/environment.lua
+++ b/advtrains_luaautomation/environment.lua
@@ -153,6 +153,17 @@ local static_env = {
local pos=atlatc.pcnaming.resolve_pos(parpos)
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
+ atc_send_to_train = function(train_id, command)
+ assertt(command, "string")
+ local train = advtrains.trains[train_id]
+ if train then
+ advtrains.atc.train_set_command(train, command, true)
+ return true
+ else
+ return false
+ end
+ end,
}
-- If interlocking is present, enable route setting functions