aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains_luaautomation')
-rw-r--r--advtrains_luaautomation/README.md5
-rw-r--r--advtrains_luaautomation/atc_rail.lua8
2 files changed, 13 insertions, 0 deletions
diff --git a/advtrains_luaautomation/README.md b/advtrains_luaautomation/README.md
index f285d0f..275653c 100644
--- a/advtrains_luaautomation/README.md
+++ b/advtrains_luaautomation/README.md
@@ -270,6 +270,11 @@ Each wagon has a current FC, indicating its next destination.
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"}`
+
+ - `get_fc_index()`
+ Returns a table with the current FC index for each wagon in the train. Use in conjunction with the result from `get_fc()` to find a the current FC for a wagon.
+ Command: `get_fc_index()`
+ Result: `{1, 1, 1, 2, 1}`
- `set_fc(fc_list, reset_index)`
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.
diff --git a/advtrains_luaautomation/atc_rail.lua b/advtrains_luaautomation/atc_rail.lua
index 177fa78..dd26f51 100644
--- a/advtrains_luaautomation/atc_rail.lua
+++ b/advtrains_luaautomation/atc_rail.lua
@@ -99,6 +99,14 @@ function r.fire_event(pos, evtdata, appr_internal)
end
return fc_list
end,
+ get_fc_index = function()
+ if not train_id then return end
+ local fc_index_list = {}
+ for widx, wagon_id in ipars(train.trainparts) do
+ fc_index_list[widx] = advtrains.wagons[wagon_id].fcind or 1
+ end
+ return fc_index_list
+ end,
set_fc = function(fc_list,reset_index)
assertt(fc_list, "table")
if not train_id then return false end