aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains_luaautomation/README.md')
-rw-r--r--advtrains_luaautomation/README.md36
1 files changed, 26 insertions, 10 deletions
diff --git a/advtrains_luaautomation/README.md b/advtrains_luaautomation/README.md
index 683e45c..a885075 100644
--- a/advtrains_luaautomation/README.md
+++ b/advtrains_luaautomation/README.md
@@ -255,15 +255,32 @@ In addition to the above environment functions, the following functions are avai
The interlocking system uses this property for Automatic Routesetting.
#### Shunting Functions and Variables
-There are several functions available especially for shunting operations. Some of these functions make use of Freight Codes (FC) set in the Wagon Properties of each wagon and/or locomotive:
+There are several functions available especially for shunting operations.
+Some of these functions make use of Freight Codes (FC) set in the Wagon Properties of each wagon and/or locomotive.
+FCs are composed of codes separated by exclamation marks (`!`), for instance `"foo!bar!baz"`.
+Each wagon has a current FC, indicating its next destination.
- `split_at_index(index, atc_command)`
Splits the train at the specified index, into a train with index-1 wagons and a second train starting with the index-th wagon. The `atc_command` specified is sent to the second train after decoupling. `"S0"` or `"B0"` is common to ensure any locomotives in the remaining train don't continue to move.
+ `index` must be more than 1 to avoid trying to decouple the very front of a train.
+
Example: train has wagons `"foo","foo","foo","bar","bar","bar"`
Command: `split_at_index(4,"S0")`
Result: first train (continues at previous speed): `"foo","foo","foo"`, second train (slows at S0): `"bar","bar","bar"`
+ - `get_fc()`
+ Returns a table with the entire FC list for each wagon in the train.
+ Command: `get_fc()`
+ Result: `{"", "foo!bar", "testing", "fc_1!fc_2!fc_3!?", "hello_world"}`
+
+ - `set_fc(fc_list)`
+ Overwrites the FC list according to a table `fc_list`. A false or nil entry will leave the wagon unaffected, however all others will be overwritten.
+ Useful for mass-programming freight trains that use FC-shunting instead of walking to each wagon individually.
+ Example: train has FC lists: `"", "foo!bar", "testing", "fc_1!fc_2!fc_3!?", "hello_world"`
+ Command: `set_fc({"", "foo!turtle", nil, "4tehlulz", false})`
+ Result: `""` `"foo!turtle"` `"testing"` `"4tehlulz"` `"hello_world"`
+
- `split_at_fc(atc_command, len)`
Splits the train in such a way that all cars with non-empty current FC of the first part of the train have the same FC. The
`atc_command` specified is sent to the rear part, as with split_at_index. It returns the fc of the cars of the first part.
@@ -287,15 +304,11 @@ There are several functions available especially for shunting operations. Some o
first part of the train as above.
- `step_fc()`
- Steps the FCs of all train cars forward. FCs are composed of codes
- separated by exclamation marks (`!`), for instance
- `"foo!bar!baz"`. Each wagon has a current FC, indicating its next
- destination. Stepping the freight code forward, selects the next
- code after the !. If the end of the string is reached, then the
+ Steps the FCs of all train cars forward, selecting the next
+ code after the `!`. If the end of the string is reached, then the
first code is selected, except if the string ends with a question
mark (`?`), then the order is reversed.
-
- `train_length()`
returns the number of cars the train is composed of.
@@ -312,13 +325,16 @@ Deprecated:
#### Interlocking
-This additional function is available when advtrains_interlocking is enabled:
+These additional functions are available when advtrains_interlocking is enabled:
- - `atc_set_disable_ars(boolean)`
+ - `atc_set_ars_disable(boolean)`
Disables (true) or enables (false) the use of ARS for this train. The train will not trigger ARS (automatic route setting) on signals then.
- Note: If you want to disable ARS from an approach callback, the call to `atc_set_disable_ars(true)` *must* happen during the approach callback, and may not be deferred to an interrupt(). Else the train might trigger an ARS before the interrupt fires.
+ Note: If you want to disable ARS from an approach callback, the call to `atc_set_ars_disable(true)` *must* happen during the approach callback, and may not be deferred to an interrupt(). Else the train might trigger an ARS before the interrupt fires.
+ - `section_occupancy(section_id)`
+ Returns a table of train ids for the specified section, nil if no section id is provided, false if the section id is invalid, an empty table if the section id is valid but empty of trains.
+
#### Approach callbacks
The LuaATC interface provides a way to hook into the approach callback system, which is for example used in the TSR rails (provided by advtrains_interlocking) or the station tracks (provided by advtrains_lines). However, for compatibility reasons, this behavior needs to be explicitly enabled.