Circuits with TrainsStops, how to do pause only when red signal is present and = 1
-
- Filter Inserter
- Posts: 665
- Joined: Wed Sep 16, 2020 12:45 pm
- Contact:
Circuits with TrainsStops, how to do pause only when red signal is present and = 1
I'm trying to add a wait condition such that the train doesn't leave the train stop if there is both a signal present and red signal=1 (the signal which comes from a nearby rail signal)
It should leave if the red signal is not present. I also have an and clause of wait 30 seconds.
I've tried using the Everything signal to detect a lack of signal, but that doesn't seem to work. My guess is there is a signal present on the Train which is blocking it from evaluating to true (Train identifier?).
Is this possible? Or do I have to wire up every train stop?
It should leave if the red signal is not present. I also have an and clause of wait 30 seconds.
I've tried using the Everything signal to detect a lack of signal, but that doesn't seem to work. My guess is there is a signal present on the Train which is blocking it from evaluating to true (Train identifier?).
Is this possible? Or do I have to wire up every train stop?
OptimaUPS Mod, pm for info.
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
Put a normal signal after a train stop and connect the signal with red or green wire to the train stop, like this: By the way, I think it would be better to negate the condition: Don't make the train leave if the signal IS NOT RED, but on IS GREEN: Of course, you can also use combinators to set the signal: If the constant combinator is turned off, the signal will be green and the condition in the train schedule will be true.blazespinnaker wrote: ↑Wed Oct 06, 2021 5:01 amIt should leave if the red signal is not present. I also have an and clause of wait 30 seconds.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
-
- Filter Inserter
- Posts: 665
- Joined: Wed Sep 16, 2020 12:45 pm
- Contact:
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
may be missing something here. Circuits tend to make my head hurt because ops I assume as always present (such as variable existence checks) don't seem to be present.
Rather than trying to re-explain or try to poke holes in your explanation, let me start by just asking a simple question - if the stop is not wired up at all (no combinators, signals, or wires connected to the train stop), will it still proceed after 30 seconds?
Eg, here is the condition (note time fully expired):
And here is the stopped train:
Only by deleting the circuit condition in the train route, will the train proceed.
Obviously, the condition won't work as no green signal is present. But that's the crux of the problem. I have many train stops all with the same name but only one of those stops I particularly want to signal. I'm wondering if I have to wire them all up or if there is some default behavior I can rely on.
As mentioned above, I tried the Everything virtual signal, but it didn't help.
Rather than trying to re-explain or try to poke holes in your explanation, let me start by just asking a simple question - if the stop is not wired up at all (no combinators, signals, or wires connected to the train stop), will it still proceed after 30 seconds?
Eg, here is the condition (note time fully expired):
And here is the stopped train:
Only by deleting the circuit condition in the train route, will the train proceed.
Obviously, the condition won't work as no green signal is present. But that's the crux of the problem. I have many train stops all with the same name but only one of those stops I particularly want to signal. I'm wondering if I have to wire them all up or if there is some default behavior I can rely on.
As mentioned above, I tried the Everything virtual signal, but it didn't help.
OptimaUPS Mod, pm for info.
-
- Filter Inserter
- Posts: 665
- Joined: Wed Sep 16, 2020 12:45 pm
- Contact:
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
If it's not possible, I will probably resort to a hack using one of the other conditions such as cargo count. I'll remove the cargo item once the rail signal light changes to green.
OptimaUPS Mod, pm for info.
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
Yes, you must hook up the signal to the train stop! It's even in the name: "Circuit condition". If you want to check something on the circuit network, you must feed something into it.blazespinnaker wrote: ↑Wed Oct 06, 2021 1:44 pmRather than trying to re-explain or try to poke holes in your explanation, let me start by just asking a simple question - if the stop is not wired up at all (no combinators, signals, or wires connected to the train stop), will it still proceed after 30 seconds?
One thing you should be aware of: In Lua, "x = 0" and "x = nil" are two different things. In the first case, you set x to the number 0, in the second case, you remove x altogether. With combinators, any signal that is not on the wire will default to a value of 0. So if you set the condition to "RED == 0", it will always be true if the signal is not connected, as well as if the signal is connected but green.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
-
- Filter Inserter
- Posts: 665
- Joined: Wed Sep 16, 2020 12:45 pm
- Contact:
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
Yeah, but that's exactly what I don't want to do
And I believe the everything virtual signal is exactly for this use case. However, it doesn't work with trains as there are semi-hidden signals present.
For some reason, likely performance, wube didn't add an op which checks for a specific signal presence.
And I believe the everything virtual signal is exactly for this use case. However, it doesn't work with trains as there are semi-hidden signals present.
For some reason, likely performance, wube didn't add an op which checks for a specific signal presence.
OptimaUPS Mod, pm for info.
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
!= 0 is the condition for "signal present". The signal being present and having a nonzero value are the same thing in Factorio circuit logic.
If you want to be able to inhibit a train from leaving a stop until it gets a signal but have the train be allowed to leave if the station isn't hooked up to a circuit network then just make the condition "red = 0" and send a red signal of 1 if you want the train to stick around.l (i.e. invert your input signal). Stops with no wire connected will not prevent the train from leaving because if no wire is connected the red signal will be zero.
If you want to be able to inhibit a train from leaving a stop until it gets a signal but have the train be allowed to leave if the station isn't hooked up to a circuit network then just make the condition "red = 0" and send a red signal of 1 if you want the train to stick around.l (i.e. invert your input signal). Stops with no wire connected will not prevent the train from leaving because if no wire is connected the red signal will be zero.
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
What is this other signal? If the red signal's 1 there's a signal present. Depart on red=0 and timer expired seems to match that part of your description, but that "both" hints at something else.blazespinnaker wrote: ↑Wed Oct 06, 2021 5:01 am[wait if] there is both a signal present and red signal=1 (the signal which comes from a nearby rail signal)
It should leave if the red signal is not present. I also have an and clause of wait 30 seconds.
You can add a further set of conditions, timer expired and red = 0 or timer expired and iron-ore = 0 if it's that specific other signal. If you mean *any* other signal, i.e. wait if red = 1 and anything else also nonzero, that will take wiring, if these other signals won't ever be negative just each * red ⇒ red and your departure condition is red < 2; for howitzer-proof you need an each != 0 ⇒ 1 each so things don't cancel out.
-
- Filter Inserter
- Posts: 665
- Joined: Wed Sep 16, 2020 12:45 pm
- Contact:
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
Interesting, I admit I didn't try that outside of train context as it wasn't relevant to my problem here. I did try that with trains (and many other combinations).
Anyways, that doesn't work. Eg:
Train still doesn't move until I delete the circuit condition. (Again, no wires connected to Train stop)
Anyways, that doesn't work. Eg:
Train still doesn't move until I delete the circuit condition. (Again, no wires connected to Train stop)
OptimaUPS Mod, pm for info.
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
Interesting. Seems I have to revise my earlier statement:blazespinnaker wrote: ↑Wed Oct 06, 2021 4:47 pmTrain still doesn't move until I delete the circuit condition. (Again, no wires connected to Train stop)
Apparently, circuit connections will only be evaluated if the trainstop is connected to something -- a signal, a combinator, or any other entity with a connector -- on the circuit network.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
Ah. For all other entities it's only possible to set circuit conditions in the UI if there's a circuit wire connected (as the UI doesn't appear otherwise), and if the wire is disconnected the condition is ignored (though still retained if you reconnect a wire). For train schedules the UI isn't directly associated with a particular train stop entity so it doesn't have any way to know whether the stop will have a wire or not.. and I guess this is the result? You might want to report that as a bug but I'm not sure what the behaviour really *should* be.blazespinnaker wrote: ↑Wed Oct 06, 2021 4:47 pmInteresting, I admit I didn't try that outside of train context as it wasn't relevant to my problem here. I did try that with trains (and many other combinations).
Anyways, that doesn't work. Eg:
train.png
Train still doesn't move until I delete the circuit condition. (Again, no wires connected to Train stop)
In any case if that doesn't work then I think you can safely assume that what you want is not currently possible; there's no alternative way to do this that might work. Does it work if you just connect a wire between the stop and a random electric pole with no other circuit components connected, and enable "send to train" in the train stop options? If so then that might be the easiest workaround; just make sure you have a wire connection in your blueprints even if it's to nothing, and then use signal=0 as the condition as I suggested.
-
- Filter Inserter
- Posts: 665
- Joined: Wed Sep 16, 2020 12:45 pm
- Contact:
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
Hard to search on bugs for train circuit conditions signals. :p
I just went and wired up all the stops, one time pain. TG you can paste in wires.
Probably quite an edge case
I just went and wired up all the stops, one time pain. TG you can paste in wires.
Probably quite an edge case
OptimaUPS Mod, pm for info.
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
As far as I know, a 0 signal is the same in Factorio as a “null” signal. That is, if there is a CC that has Red = 1 and you have something else that outputs to that wire a Red = -1, then the two would cancel out and there would no longer be any Red signal. Its not a case of Red = 0, as that implies there is a Red signal that has a value of 0.
Instead of telling the train to “Wait when the Red signal is 1”, tell it to “Wait until Red < 0”.
Have that Rail Signal output its signal to the Train Stop. It will set Red to 1, or leave Red alone, depending on what color the Rail Signal is. Also wire to the Train Stop a Constant Combinator, outputting Red = -1.
If the Rail Signal is Red, it outputs Red = 1 and that gets added to the -1 from the CC, removing Red as a signal on the wire. Red is no longer less than zero, so the train would wait.
If the Rail Signal is anything other than Red, it does not add Red = 1 to the circuit, so the CC value of Red = -1 stands, and the train can happily move on.
I’ll do something similar when making a Building Train style setup. CC outputs the negative amount of the minimum material I want on hand (-8 Nuclear Reactors, -350 Heat Pipe, etc. - what exactly depends on the Building Train). That then gets wired to the output chests at the station, and whatever is in those will build up and render positive the item signals (or straight up zero them out). Train Station is Enabled when Anything < 0. This used to be that trains were generally set up prior to the addition of Train Stop Limits. I still use this for building trains, where there is only exactly one train that has that stop on its schedule and its an “on demand” type of schedule where the train only has to visit any one station only occasionally.
Instead of telling the train to “Wait when the Red signal is 1”, tell it to “Wait until Red < 0”.
Have that Rail Signal output its signal to the Train Stop. It will set Red to 1, or leave Red alone, depending on what color the Rail Signal is. Also wire to the Train Stop a Constant Combinator, outputting Red = -1.
If the Rail Signal is Red, it outputs Red = 1 and that gets added to the -1 from the CC, removing Red as a signal on the wire. Red is no longer less than zero, so the train would wait.
If the Rail Signal is anything other than Red, it does not add Red = 1 to the circuit, so the CC value of Red = -1 stands, and the train can happily move on.
I’ll do something similar when making a Building Train style setup. CC outputs the negative amount of the minimum material I want on hand (-8 Nuclear Reactors, -350 Heat Pipe, etc. - what exactly depends on the Building Train). That then gets wired to the output chests at the station, and whatever is in those will build up and render positive the item signals (or straight up zero them out). Train Station is Enabled when Anything < 0. This used to be that trains were generally set up prior to the addition of Train Stop Limits. I still use this for building trains, where there is only exactly one train that has that stop on its schedule and its an “on demand” type of schedule where the train only has to visit any one station only occasionally.
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
Please report that as a bug. A train with condition "red = 0" should leave a stop with no wire connected. A 0 is encoded as signal not present so that should already make the train leave. Further other entities ignore the circuit conditions when no wire is connected. E.g. take a belt with wire and set it to "R = 1". Then remove the wire or cut&paste just the belt. The belt with run again. Connect a wire and the belt stops again. Same with pumps, ...
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
Yes, X == 0 is exactly the same as "there is no signal X". I agree it is very confusing that it doesn't evaluate to true if it's not connected to any network. Figuring out how the circuit network at the start is already very difficult due to all the weird rules and exceptions, this is yet another weird exception you have to learn unless they actually decide to change this behavior. The best tip I know of is to connect specifically a power pole to whatever cable's signals you want to inspect, as it will show them all on the pole.
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
And another oddity. If you set the train stop to output the train count as C and connect a green wire then the train stop sees the number of trains targeting the station. So you could set the train to leave on C=2, i.e. as soon as a second train targets the station. Then one train leaves when another arrives.
But now connect the red wire too. Now the stop sees double the number, C=2, C=4, C=6, ... Same goes for belts.
But for requester chests I believe you can read the contents and set the requests and not have the chests own contents get added to the requests.
But now connect the red wire too. Now the stop sees double the number, C=2, C=4, C=6, ... Same goes for belts.
But for requester chests I believe you can read the contents and set the requests and not have the chests own contents get added to the requests.
-
- Filter Inserter
- Posts: 665
- Joined: Wed Sep 16, 2020 12:45 pm
- Contact:
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
That's actually consistent behavior. It sums the signals in the network and you're sending it in via two separate channels.
OptimaUPS Mod, pm for info.
Re: Circuits with TrainsStops, how to do pause only when red signal is present and = 1
Unfortunately not. Setting requests and reading contents are mutually exclusive options. (Perhaps precisely because the undesirable positive feedback would be unavoidable.)