LTN - Logistic Train Network

by Optera

Adds logistic-train-stops acting as anchor points for building a fully automated, train logistic network. It can handle all possible train configuration. Just send all trains to depots and LTN will pick the best suitable train for a job. LTN cuts the amount of rolling stock required to run a megabase down to 30% or less. With cargo ships installed also adds a logistic port for ships.

Content
17 days ago
0.14 - 2.0
257K
Trains Circuit network

b Non recoverable error

22 days ago

When i set up a depot i place down the station and then proceed to make the constant combinator with a stop depot and an encoded network id. When i then connect it to the station it comes with this error:

The mod LTN - Logistic Train Network (2.3.0) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event LogisticTrainNetwork::on_nth_tick(2)
LogisticTrainNetwork/script/tools.lua:42: assertion failed!
stack traceback:
[C]: in function 'assert'
LogisticTrainNetwork/script/tools.lua:42: in function 'getDepots'
LogisticTrainNetwork/script/stop-update.lua:214: in function 'UpdateStop'
LogisticTrainNetwork/script/dispatcher.lua:50: in function <LogisticTrainNetwork/script/dispatcher.lua:24>

I have tried to remove other mods to see if they were interfeering with it but it still happens. I have also tried to change some of the settings but nothing works.

22 days ago
(updated 21 days ago)

Subject: Error Report: Logistic Train Network (LTN) v2.3.0 in Factorio 2

Hello,

I encountered an error while using the Logistic Train Network (LTN) mod (version 2.3.0) in Factorio 2. The error occurred shortly after I placed a blueprint containing a Logistic Train Stop. The issue seems to have arisen as the structure was being constructed.

Here is the error message:

The mod LTN - Logistic Train Network (2.3.0) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event LogisticTrainNetwork::on_nth_tick(2)
LogisticTrainNetwork/script/tools.lua:42: assertion failed!
stack traceback:
[C]: in function 'assert'
LogisticTrainNetwork/script/tools.lua:42: in function 'getDepots'
LogisticTrainNetwork/script/stop-update.lua:214: in function 'UpdateStop'
LogisticTrainNetwork/script/dispatcher.lua:50: in function <LogisticTrainNetwork/script/dispatcher.lua:24>

After reviewing the code in the function, I believe the issue may stem from being accessed before it is properly initialized or populated. To improve robustness and avoid the error, I would like to suggest the following modification:

---@return ltn.TrainStop[][]
function Tools.getDepots()
if not storage.Depots or #storage.Depots == 0 then
log("Warning: Depots are not initialized or empty.") -- Logs the situation for debugging.
return {} -- Safely returns an empty table to prevent the error.
end
return storage.Depots
end

This adjustment ensures that the function handles cases where is invalid or empty without triggering an assertion failure. Additionally, the log provides insight into potential issues for debugging.

Thank you for your hard work and for providing such a fantastic mod!
Best regards,

16 days ago

This should be fixed in the current release.

New response