aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation
diff options
context:
space:
mode:
author1F616EMO <root@1f616emo.xyz>2026-01-30 17:52:54 +0800
committerorwell <orwell@bleipb.de>2026-03-22 17:32:36 +0100
commit067f1f0d22231d1006f71699d3ef9006a1c38064 (patch)
tree2ef824105dc16880d704b9a7271e2cabf509e30b /advtrains_luaautomation
parenta0e97313eb670ae3f52391b8d1f36a1043f805b2 (diff)
Aadd get_wagon_train_id for retrieving train ID from wagon ID
Context: https://chatlog.1f616emo.xyz/chat/1f616emoluanti/2026/01/30/#L147
Diffstat (limited to 'advtrains_luaautomation')
-rw-r--r--advtrains_luaautomation/environment.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua
index 50eca7c..4d4ac47 100644
--- a/advtrains_luaautomation/environment.lua
+++ b/advtrains_luaautomation/environment.lua
@@ -161,6 +161,10 @@ local static_env = {
if not train then return false end
return table.copy(train.trainparts or {})
end,
+ get_wagon_train_id = function(wagon_id)
+ local wagon = advtrains.wagons[wagon_id]
+ return wagon and wagon.train_id or false
+ 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")