diff options
author | Maverick2797 <git.maverick2797@gmail.com> | 2024-10-30 21:06:29 +0800 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2024-11-09 22:32:23 +0100 |
commit | 715efe22939bbe472ba4a2c81c74e64c45726bc2 (patch) | |
tree | bd7cffc02bcc1ecf958f14930a8a3f2ed4c480f8 /advtrains_luaautomation | |
parent | 322fc31e74151a0ce6a14b49185b0ec9000ff5b2 (diff) | |
download | advtrains-715efe22939bbe472ba4a2c81c74e64c45726bc2.tar.gz advtrains-715efe22939bbe472ba4a2c81c74e64c45726bc2.tar.bz2 advtrains-715efe22939bbe472ba4a2c81c74e64c45726bc2.zip |
Add get_fc_index() fucntion
Diffstat (limited to 'advtrains_luaautomation')
-rw-r--r-- | advtrains_luaautomation/README.md | 5 | ||||
-rw-r--r-- | advtrains_luaautomation/atc_rail.lua | 8 |
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 |