I'm experiencing a weird behavior after adding the train limit function to my artillery outposts in Factorio 1.1.5:
I have supply boxes (for example turrets) hooked up to a circuit so the train limit is set to 1 if there is less than x of a certain item. This calls 1 train into the outpost, the train stays until there are a few seconds of inactivity, ie. the missing item has been unloaded and then the train leaves. I also enable the artillery signal with a similar circuitry (for example ammo), so the artillery only fires if the outpost can defend itself.
Separately, both of these functions work perfectly fine. As soon as I combine them, the following happens:
Take out item out of box to test. Train limit is increased to 1 and Train A moves to Outpost. Train A enters Outpost Station and the artillery is enabled. Now train A is not recognizing its reservation of the station anymore. It says "Destination full", but still wants to go to the outpost. Additionally, Train B from the Main base is now reserving the spot inside the outpost and is driving to it, but can't enter, because train A is physically inside the Outpost. Train A is also not being unloaded. It's as if as soon as it enters the station, it's being kicked out. My suspicion is that somehow, this "kick" is related to this mod and its signal check.
If I send train A back to main base manually, train B enters the outpost. Upon entering, the artillery is enabled AND I get the message: "Destination full". This means that train B is also being "kicked out" of its reservation and wants to enter the Outpost even though it's inside the Outpost station. However, since there are only 2 trains available and train A is on its way back to main base, the reservation "reverts back" to train B and it's properly unloaded.
I did a few tests to confirm that the issue has something to do with the Artillery signal:
-
Remove the artillery signal from the outpost.
Result: problem gone
-
Keep artillery signal, but enable artillery with the signal in main base (instead of disabling it). So the artillery still gets a signal, but it's not one to change its state.
Result: problem gone
-
Do the test with an item that is also part of the artillery signal circuitry, ie ammo. This means that the artillery signal isn't present upon entering the station, but only gets send to the train once enough ammo has been unloaded.
Result: problem appears as soon as the signal is sent. Now train A gives the purple warning "Destination fulL" as soon as the ammo is unloaded and it receives the signal to enable artillery. It still wants to go to the outpost, but can't. When actually, it could leave 15 seconds after the ammo has been unloaded. Also train B isn't called, because the train limit isn't set to 1 anymore, since the ammo has been refilled.
-
Switch from enabling at Outpost and disabling at main base to disabling at Outpost and enabling at main base.
Result: same error
-
Set train B to manual mode.
Result: Problem gone. It's the same as when the other train is on its way back to main base - it's not available to go to the Outpost, so it can't "steal" the reservation.
As soon as I can replicate this bug without this mod, I'm going to post a bug report on the Factorio forum. But so far I've only seen this happening if the artillery signal changes a train from manual to auto or from auto to manual.