Hi, in my playthrough I have export stations and import stations. it's a many to many vanilla train network with export stations having fix amount of trains being always available at stackers and import stations with changing limits(if they need more materials their train limits can be up to 3 for example or 0 if they don't need anything).
anyway here's the problem. when a train needs to refuel and the next station is an import station. the train sometimes doesn't leave fuel station because the destination station is full and even when it's not full probably is going to be filled with another one of many trains that can serve that import station which results in train being stuck to the fuel station. I came up with a solution to this by adding another "fuel-station-insert-order". I called the new value "before-loop-start" which inserts the fuel station to index 1 always. My train schedules look like this:
Export: iron #1
cargo full
Import: iron
cargo empty
so this way it doesn't add the fuel station between export and import and adds it always before everything else in the loop. it looks like this with this option selected:
Fuel Station
inactivity
Export: iron #1
cargo full
Import: iron
cargo empty
which is fine because the export station can always accept the fixed amount of trains.
these are the changes I made:
control.lua
function AddSchedule(train)
local schedule = train.schedule or {records = {}, current = 1}
for _,record in pairs(schedule.records) do
if record.station == global.TrainStopName then return end
end
local record = {station = global.TrainStopName, wait_conditions = {{type = "inactivity", compare_type = "and", ticks = 120 }}}
if settings.global['fuel-station-insert-order'].value == "go-after" then
table.insert(schedule.records,schedule.current + 1,record)
elseif settings.global['fuel-station-insert-order'].value == "before-loop-start" then
table.insert(schedule.records, 1, record)
else
table.insert(schedule.records,schedule.current,record)
end
train.schedule = schedule
end
settings.lua
allowed_values = {"go-first", "go-after", "before-loop-start"}
locale/en/base.cfg
fuel-station-insert-order-before-loop-start=before loop starts
I'm not going to make a new mod because of this but I think it would be a nice option for this mod to have it.