aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2020-08-21 15:58:12 +0200
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2020-08-21 15:58:12 +0200
commitb23d346ace0219b1e6c61b85f4a06a90d3a0e962 (patch)
treee4f6ec40b9a0c999bb42f13e608e89b943381d7a /advtrains
parent36d8c8b7162b3b6ba6cc0a7f98b0dc295024ecd8 (diff)
downloadadvtrains-b23d346ace0219b1e6c61b85f4a06a90d3a0e962.tar.gz
advtrains-b23d346ace0219b1e6c61b85f4a06a90d3a0e962.tar.bz2
advtrains-b23d346ace0219b1e6c61b85f4a06a90d3a0e962.zip
add maximum length parameter to split_at_fc and split_off_locomotive
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/trainlogic.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index c39cc7a..cc34b4f 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -892,16 +892,21 @@ function advtrains.spawn_wagons(train_id)
end
end
-function advtrains.split_train_at_fc(train, count_empty)
+function advtrains.split_train_at_fc(train, count_empty, length_limit)
-- splits train at first different current FC by convention,
-- locomotives have empty FC so are ignored
-- count_empty is used to split off locomotives
+ -- length_limit limits the length of the first train to length_limit wagons
local train_id = train.id
local fc = false
local ind = 0
for i = 1, #train.trainparts do
local w_id = train.trainparts[i]
local data = advtrains.wagons[w_id]
+ if length_limit and i > length_limit then
+ ind = i
+ break
+ end
if data then
local wfc = advtrains.get_cur_fc(data)
if wfc ~= "" or count_empty then