[2.0.68] Train stops read train content messes with interrupts in a bad way
Posted: Mon Sep 29, 2025 10:42 am
Attached is a game where a train interrupt fires when it shouldn't.
The train is supposed to get crude oil when there is less than 25k in the storage tanks. At the time of the save it is approaching that limit and the train leaves to get crude oil. When the train comes back it fills the storage tanks but then the interrupt triggers again despite there being enough crude oil present.
I believe the problem is the train stops "Read train contents". My guess is that right when the fluid wagon is empty and the "empty cargo" condition is met the train stop still reports the fluid value from the last tick to the circuit network so the "signal parameter > 0" is also met.
I also attached two saves that won't fire the interrupt. I first tried it without read content, which means the pumps will interfere with each other. So not a solution. Secondly I subtract the train content on the red wire from the green wire, adding another tick delayed value. That way signal value seen by the interrupt will be slightly negative until the fluid wagon has been empty for 2 (I think) ticks. While that works it's quite unsatisfactory.
If my analysis is correct and the read train content reads produces a 1 tick delayed signal then I can think of three fixes:
1) add a color selector to the train stops "Read train content" and the interrupts "Circuit" condition. That way the train content can be put on the red wire and the interrupt fire on the green wire.
2) interrupt conditions should not be checked on the tick the train becomes ready but one tick later giving the train stop time to update the circuit network
3) the cargo empty condition should fire 1 tick after the train was empty, again giving the train stop time to update the circuit network
The train is supposed to get crude oil when there is less than 25k in the storage tanks. At the time of the save it is approaching that limit and the train leaves to get crude oil. When the train comes back it fills the storage tanks but then the interrupt triggers again despite there being enough crude oil present.
I believe the problem is the train stops "Read train contents". My guess is that right when the fluid wagon is empty and the "empty cargo" condition is met the train stop still reports the fluid value from the last tick to the circuit network so the "signal parameter > 0" is also met.
I also attached two saves that won't fire the interrupt. I first tried it without read content, which means the pumps will interfere with each other. So not a solution. Secondly I subtract the train content on the red wire from the green wire, adding another tick delayed value. That way signal value seen by the interrupt will be slightly negative until the fluid wagon has been empty for 2 (I think) ticks. While that works it's quite unsatisfactory.
If my analysis is correct and the read train content reads produces a 1 tick delayed signal then I can think of three fixes:
1) add a color selector to the train stops "Read train content" and the interrupts "Circuit" condition. That way the train content can be put on the red wire and the interrupt fire on the green wire.
2) interrupt conditions should not be checked on the tick the train becomes ready but one tick later giving the train stop time to update the circuit network
3) the cargo empty condition should fire 1 tick after the train was empty, again giving the train stop time to update the circuit network