LuaATC add trainparts(train_id)

Returns a copy of the trainparts table to allow tracking individual wagon ids
Also fixed a couple of file permissions from previous commits
This commit is contained in:
Maverick2797 2024-08-30 17:25:01 +08:00 committed by orwell
parent 55108ae38e
commit 852e2f4219
3 changed files with 9 additions and 0 deletions

View File

@ -93,6 +93,9 @@ Removes any pending interrupts of this node.
Make this active component send a digiline message on the specified channel.
Not available in init code.
- `trainparts(train_id)`
returns a table with the ids of the cars the train is composed of, or false if `train_id` is invalid. `train_id` can be replaced with `atc_id` when used in LuaATC Rails.
- `atc_send_to_train(<train_id>, <atc_command>)`
Sends the specified ATC command to the train specified by its train id. This happens regardless of where the train is in the world, and can be used to remote-control trains. Returns true on success. If the train ID does not exist, returns false and does nothing. See [atc_command.txt](../atc_command.txt) for the ATC command syntax.

View File

@ -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")

0
advtrains_luaautomation/operation_panel.lua Executable file → Normal file
View File