I didn't yet find a way to make a 100%-safe crossing, is there one I missed? Most of the other implementations (priorizing the player when there, and keeping the signals green otherwise, as well as not allowing deadlocks, aka stopping both player and train until someone backs off) fail on trains running over signals that were yellow before closing. I'd like to close the signal, and then ask the signal, whether the section before it is safe (would be green if not closed, as it already is, when a train is stopped directly before the signal), but closed signals apparently don't return a color signal.
I've tried my own implementation, assuming it is safe when i close a signal when it has been green before; but the circuit network is too slow, allowing a train to switch the signal to yellow after examining it, but before I am fast enough to close it and stop the train:
- factrainsio.gif (1.73 MiB) Viewed 4610 times
(Don't try to connect the states of the different elements, the screenshot-gif software was too slow to actually capture consistent frames, causing green presignals before red signals and vice-versa.)
- ">": If "green" > 0, output "green" := 1 // if signal is green or gates are already open (signal is already red), it is safe to open the gates
- "*": output "O" (Open Gates, Close Signal) := "green" * "G" (Player near) // if it is safe to open the gates, and there is a player, open the gates
- "+": output "green" := "O" // rename signal to allow adding "O" from "*" and "green" from signal; might as well have been an explicit addition
It start's oscillating, apparently not being able to decide whether I or the train was there first.
Using two signals for determining the state didn't work for me in earlier attempts, it either fails at the moment where the first (examined) signal is yellow, but the second (closed) signal still green, causing the train to stop, with me keeping the gates closed although the train has stopped, or at the moment where the first (closed) signal was yellow), but the second (examined) one still green; causing me to open the gates for a short moment (until the examined signal turns yellow), although the train will run over the red signal. Is there any solution to get (or calculate) the closed signal state, or would that require a mod?
EDIT: I tried
mrnicosable'atloomis's suggestion. It work's better than i expected; but I still have to test if the gates-closing-animation is short enough to prevent me from running into between both gates with 10 exoskeletons or a car. I think that latency might be to long, if the gates only start closing if it is already too late to stop the train.
EDIT2: 0.13
*almost* fixes this suggestion. With 10 exoskeletons one is still able to run on the tracks when it's to late for the train to stop. Took me about 20-30 attempts, but it is possible. Yay, I died.
One more try: when the signal is closed, it doesn't send green, it send's nothing. But when the signal is yellow or red due to a train passing (tested with pre-signal to allow working with slower trains), it sends red / yellow. That might be useful.
EDIT 3: Might have a foolproof solution; will anyone check for bugs?
- 2016-08-20 21_36_17-Factorio 0.13.17pdn.png (3.78 MiB) Viewed 4600 times
It might still be necessary to delay the "G" signal by one tick to make sure it doesn't arrive before the "red" signal if player and train are recognized in the same moment and cause the gate to open for 1/60 second; but I haven't been able to run in front of the train like this. (Maybe train movement and the player induced "G" signal are not computed in parallel.)
The gates (I was surprised when I the gate suddenly opened w/o the first comparator) are also interesting, one could make a tetris game...
- 2016-08-20 21_56_43-Factorio 0.13.17.png (153.14 KiB) Viewed 4600 times