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,