LTN sometimes sends deliveries to stations that don't request them
Posted: Tue Feb 01, 2022 1:09 pm
**Error message or bug description**
LTN sometimes sends more trains than a station needs. This causes cargo to be left over.
**To Reproduce**
Observed with the following sequence (note that this stop has a maximum trains of 1).
1. A train supplies 8000 iron plates.
2. The requester asks for slightly more than this, say, 10000 iron plates.
3. The train arrives.
4. LTN calculates a new request value, say, 2000 iron plates.
5. LTN queues a request for this value.
6. The existing 8000 iron plates are unloaded, and in response, the circuit network attached changes the request value to zero.
7. LTN queues a delivery of 2000 iron plates after the train is emptied, and left, even though the requested value is zero.
8. This causes the station to not unload all the cargo, creating a Mess.
**LTN version**
1.16.7
**Log file**
[factorio-previous.log](https://github.com/Yousei9/Logistic-Tra ... evious.log)
I performed some testing with the Carrick Greenmere station. There's a log entry about resetting train signals, but this doesn't seem to reconsider requests.
The broader context is that the "request threshold" signal did not work for me in practice because to avoid leftover cargo in the train, each wagon must be considered individually. If you need more than 8000 iron plates but each wagon is connected to separate belts and only one can unload, the other wagon has cargo left over. Therefore I created a circuit network to apply my own request threshold which considers each wagon individually and only requests when all wagons can be unloaded. This works completely fine except in the above case where recalculating the request value does not work as expected. It's not clear how to fix this in the circuit network either as although you can read out the train contents from the stop, the logic must be applied per wagon, rather than per train, and the circuit network can't read out the contents of each wagon, so you don't know whether all wagons can unload or not.
The expected behaviour is that regardless of what circuit-network shenanigannery I might implement to decide the requested value, this may depend on having finished unloading the previous train first, so LTN should not decide future deliveries until after the train is unloaded and the new circuit signals received. I guess that there is some problem with arbitrary circuit networks taking arbitrary time to update, but some small threshold like 10-20 ticks should cover virtually all networks in practice? Alternatively, you could simply determine that stations which can't unload all wagons evenly are simply not supported, which would certainly make quite a few things simpler, but this is not something I found documented or mentioned in tutorials.
LTN sometimes sends more trains than a station needs. This causes cargo to be left over.
**To Reproduce**
Observed with the following sequence (note that this stop has a maximum trains of 1).
1. A train supplies 8000 iron plates.
2. The requester asks for slightly more than this, say, 10000 iron plates.
3. The train arrives.
4. LTN calculates a new request value, say, 2000 iron plates.
5. LTN queues a request for this value.
6. The existing 8000 iron plates are unloaded, and in response, the circuit network attached changes the request value to zero.
7. LTN queues a delivery of 2000 iron plates after the train is emptied, and left, even though the requested value is zero.
8. This causes the station to not unload all the cargo, creating a Mess.
**LTN version**
1.16.7
**Log file**
[factorio-previous.log](https://github.com/Yousei9/Logistic-Tra ... evious.log)
I performed some testing with the Carrick Greenmere station. There's a log entry about resetting train signals, but this doesn't seem to reconsider requests.
The broader context is that the "request threshold" signal did not work for me in practice because to avoid leftover cargo in the train, each wagon must be considered individually. If you need more than 8000 iron plates but each wagon is connected to separate belts and only one can unload, the other wagon has cargo left over. Therefore I created a circuit network to apply my own request threshold which considers each wagon individually and only requests when all wagons can be unloaded. This works completely fine except in the above case where recalculating the request value does not work as expected. It's not clear how to fix this in the circuit network either as although you can read out the train contents from the stop, the logic must be applied per wagon, rather than per train, and the circuit network can't read out the contents of each wagon, so you don't know whether all wagons can unload or not.
The expected behaviour is that regardless of what circuit-network shenanigannery I might implement to decide the requested value, this may depend on having finished unloading the previous train first, so LTN should not decide future deliveries until after the train is unloaded and the new circuit signals received. I guess that there is some problem with arbitrary circuit networks taking arbitrary time to update, but some small threshold like 10-20 ticks should cover virtually all networks in practice? Alternatively, you could simply determine that stations which can't unload all wagons evenly are simply not supported, which would certainly make quite a few things simpler, but this is not something I found documented or mentioned in tutorials.