---
Adds a function to get the current value of fcind for each wagon. Not sure how to deal wih reversed fcs though?
advtrains_luaautomation/README.md | 5 +++++advtrains_luaautomation/atc_rail.lua | 8 ++++++++
2 files changed, 13 insertions(+)
diff --git a/advtrains_luaautomation/README.md b/advtrains_luaautomation/README.md
index f98f7a0..8c89237 100644
--- a/advtrains_luaautomation/README.md+++ b/advtrains_luaautomation/README.md
@@ -276,6 +276,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 b98648e..0592cd5 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
--
2.46.0