0ptera / Logistic-Train-Network

Factorio mod adding logistic network for trains.
Other
155 stars 55 forks source link

items accepted at a temporary stop can leak into the output combinator #305

Closed Quezler closed 1 year ago

Quezler commented 1 year ago

Error message or bug description If LTN caused an error message: screenshot or text of that message. If something did not work as expected: Description of the behavior and what you expected instead.

When an LTN train stops at a temporary stop, between that tick and the train stopping at the actual station on the same rail items can get loaded, which will be returned by the LTN output combinator.

This is problematic when you have a station that can load several things, for example consider such a setup: Screenshot 2022-09-25 at 10 53 57

Between requests of different items there are basically always a few leftovers, which get blacklist filtered out at the top, whilst the stuff the train is supposed to receive is whitelisted from the warehouse.

The problem lies in that when a leftover item makes it in between the tick of the temporary stop and the tick of the station you'll end up with two item signals: the "intended" one and the "stowaway"

In the situation above it would eventually resolve itself when the 512 slot warehouse gets cycled through the entire train (depending on the amount of stowaway items still in there), but stations setup like these could still get stuck in a loop: Screenshot 2022-09-25 at 10 58 13

In both pictures you can also observe my own fix, a decider combinator set to each >= 40, which means that any strangler items are basically guaranteed to be filtered out since they rarely get above just a few items, 40 of course chosen for the amount of slots in case the intended pickup are 40 unstackable items.

Of course this can be avoided if you only enable the inserters/loaders if the lamp is blue or the station outputs a train signal.

But i am hoping for a bugfix/feature that the train contents get cached for the output combinator when it arrives at the temp stop and not 1+ ticks later at the actual station, i have not yet looked at the code for the practicality of this since it'll mostly function as a psa warning to other users that this can happen, so it is at least a known issue. ^-^

(the cache should probably only stay valid for several ticks, in case the station is disabled/removed & the train reroutes elsewhere)

To Reproduce Build either of the setups shown above and have a train alternate between at least two resource pickups as described.

LTN version 1.16.10

Log file

0ptera commented 1 year ago

Trains getting loaded before arriving at the station can only be solved by changing your station design.

Smart station designs can be found here: https://forums.factorio.com/viewtopic.php?p=297643#p297643