"On Demand" Train Schedule?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
Thrillho
Burner Inserter
Burner Inserter
Posts: 7
Joined: Mon Aug 09, 2021 3:22 pm
Contact:

"On Demand" Train Schedule?

Post by Thrillho »

Hello!

This is my first post on the forum. I've been enjoying the game so far, on my third 'playthrough', on a railworld map, and was wondering if it would be possible to create an 'on-demand' train shuttle. I've been experimenting with combinators and temporary stops but I'm struggling to achieve it in a 'vanilla' fashion. The key ideas are:

1. The train loops between each outpost or base in the overall layout, stopping at designated 'park & ride' stops.
2. The train only loops between stops when a passenger is onboard; if not, it stops at one of these stops until ready to be used.
3. The train can be summoned to any particular stop without using the 'trains' menu or temporary stops; a passenger/player at any particular stop enables a circuit (either manually with a combinator/switch, or automatically using a gate as a detector) which sends a signal to the train to travel to THAT stop in particular.

The first two points are fairly easy to accomplish with a schedule consisting of all the 'park & ride' stops, with combined wait conditions of 5 seconds passing and a passenger being onboard; however, this does mean that you can only use the train by boarding it wherever it happens to be. Alternatively, you can remove the 'passenger present' requirement to have a constantly running shuttle, but this isn't as helpful as being able to summon it.
Separately, I can accomplish point 3 with a system that will summon a train to a particular stop when a condition is met (by making a circuit that will switch on the stop); but this only works when all stops are off by default, and while the train will show up, it won't go anywhere afterwards.

Now, I know that you can skip stations in a schedule by opening up the train menu and clicking on a particular station to make the train go there next, or CTRL+click to insert a temporary stop; I was wondering though if there would be a way to 'automate' this so I wouldn't have to manually dive into the train menu to achieve the same effect. I know this seems like a lot of effort to do something that's easily achievable through the menus already, but I'd like something that's a little more 'diagetic' as it were.

I can be very dim when it comes to this sort of problem, so I thought it might be worth casting my net wide as it were. Any advice or hints/tips would be appreciated, or even just a statement of "no this won't work what are you thinking". My next plan is to see if it's possible to create a factory-wide circuit network and effectively a manual 'switchboard' to hook up all stations into one circuit, but that's a lot of work and I've not thought about it seriously yet.

torne
Filter Inserter
Filter Inserter
Posts: 341
Joined: Sun Jan 01, 2017 11:54 am
Contact:

Re: "On Demand" Train Schedule?

Post by torne »

If you have a gate to "summon" the train, you could run a wire around the entire base to carry the "summon" signal everywhere, and then have a couple of combinators at each train stop to check if the global summon signal is set *and not the local summon signal* - i.e. the train was summoned somewhere else. If so then disable the train stop, so that the train has to go somewhere else. If they all do this then the train's next stop will be the place you wanted it since all the others are disabled. Then have the "summon" signal reset once the train actually arrives at the stop, and the stops will all re-enable and the train can loop through them until you get off.

I've not actually tried this out, so I may be overlooking some crucial point, but this seems plausible?

quyxkh
Smart Inserter
Smart Inserter
Posts: 1027
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: "On Demand" Train Schedule?

Post by quyxkh »

Hunt up "factorio pax trains".

astroshak
Filter Inserter
Filter Inserter
Posts: 597
Joined: Thu May 10, 2018 9:59 am
Contact:

Re: "On Demand" Train Schedule?

Post by astroshak »

I can think of a way to set the train to come to you; but what I cannot really come up with is a way to reset the system after you’ve gotten off the train.

Thrillho
Burner Inserter
Burner Inserter
Posts: 7
Joined: Mon Aug 09, 2021 3:22 pm
Contact:

Re: "On Demand" Train Schedule?

Post by Thrillho »

Thanks for the replies, guys!
quyxkh wrote:
Mon Aug 09, 2021 9:57 pm
Hunt up "factorio pax trains".
Ah, so that's the term for it - thank you. I did try searching 'on demand trains', 'personal shuttle' etc, but couldn't find anything specific. This is definitely bringing up some useful videos/suggestions.
astroshak wrote:
Tue Aug 10, 2021 12:09 am
I can think of a way to set the train to come to you; but what I cannot really come up with is a way to reset the system after you’ve gotten off the train.
That's as far as I'd got, yeah, although I don't think I was even that far - like I mentioned, I can get the train to go to a particular stop on demand, but can't get it to start moving after that point. (having all stations off by default, then using a switch - in this case using the 'pushbutton' mod though a gate would work as well - to enable that station)
torne wrote:
Mon Aug 09, 2021 9:23 pm
If you have a gate to "summon" the train, you could run a wire around the entire base to carry the "summon" signal everywhere, and then have a couple of combinators at each train stop to check if the global summon signal is set *and not the local summon signal* - i.e. the train was summoned somewhere else. If so then disable the train stop, so that the train has to go somewhere else. If they all do this then the train's next stop will be the place you wanted it since all the others are disabled. Then have the "summon" signal reset once the train actually arrives at the stop, and the stops will all re-enable and the train can loop through them until you get off.

I've not actually tried this out, so I may be overlooking some crucial point, but this seems plausible?
This seems like the next thing I was going to try, at least generally the idea of giving stations individual IDs and running a site-wide network. I like the idea of using a site ID signal to override a global signal. I might start experimenting and seeing how I can get on with this, and I'll post my updates here.

torne
Filter Inserter
Filter Inserter
Posts: 341
Joined: Sun Jan 01, 2017 11:54 am
Contact:

Re: "On Demand" Train Schedule?

Post by torne »

Thrillho wrote:
Tue Aug 10, 2021 7:50 am
torne wrote:
Mon Aug 09, 2021 9:23 pm
If you have a gate to "summon" the train, you could run a wire around the entire base to carry the "summon" signal everywhere, and then have a couple of combinators at each train stop to check if the global summon signal is set *and not the local summon signal* - i.e. the train was summoned somewhere else. If so then disable the train stop, so that the train has to go somewhere else. If they all do this then the train's next stop will be the place you wanted it since all the others are disabled. Then have the "summon" signal reset once the train actually arrives at the stop, and the stops will all re-enable and the train can loop through them until you get off.

I've not actually tried this out, so I may be overlooking some crucial point, but this seems plausible?
This seems like the next thing I was going to try, at least generally the idea of giving stations individual IDs and running a site-wide network. I like the idea of using a site ID signal to override a global signal. I might start experimenting and seeing how I can get on with this, and I'll post my updates here.
This doesn't require stations have unique IDs - the signal can always just be A=1 or whatever. You just need a way to tell the difference between the "local" and "remote" signals, which you can do just by keeping the red/green wires separate. Connect a global network of green wire to every stop's request signal; connect individual red wires only to this stop's request signal. Use a couple of deciders to enable the train stop if *either* the red wire has the signal, or if the green wire has no signal.

Combine this with a latch on each request signal. Set the latch when the button/gate/whatever is turned on. Reset the latch when the train-present signal goes from being set to not being set (i.e. falling-edge detector). Make sure the train is set to only leave when a passenger is on board plus some brief waiting time.

I think that should work. When you trigger a request at a given stop it will disable all the other stops, causing the train to path to the sole enabled stop even though it's empty. Once it arrives it will reset the request and all the stops will turn back on, but the train won't go anywhere until you get on. Once you get on it will go through all the stops in the preset order and pause at each one long enough for you to get off, and if you get off it will stop at the current stop (or next stop if you get off inbetween).

This simple system will not really work perfectly for more than one player at a time as I've described it here. If a second request gets activated while the first request is still in progress, it will still go to the first request station and will wait there until the first player gets on; then it will go directly to the second request, ignoring the other stops in the schedule. Since there's already a player on board though, it will only wait at the second stop for the wait time before leaving and returning to visiting all stops. So, it'll kinda take the first player out of their way, and the second will only get a brief window to hop on. It also won't really do anything sensible with more than one train.

torne
Filter Inserter
Filter Inserter
Posts: 341
Joined: Sun Jan 01, 2017 11:54 am
Contact:

Re: "On Demand" Train Schedule?

Post by torne »

I'm sure other people have thought of smarter systems though :)

astroshak
Filter Inserter
Filter Inserter
Posts: 597
Joined: Thu May 10, 2018 9:59 am
Contact:

Re: "On Demand" Train Schedule?

Post by astroshak »

Hmm. While I don’t think there’s a way (unless you somehow jigger it to turn signals red) to have the train use the Until Passenger Present wait condition, how’s this?

Leave the refueling station (whatever one you plan on providing it fuel at) off the circuit network, with a Train Limit of 1, so the train can always return and get topped off. Every other station that is part of the personal shuttle system, have the Train Limit dynamically set to 1. Use the Gate trigger to dynamically, using the circuit network, turn every OTHER station’s Train Limit to 0. I envision this by :

Using a Constant Combinator outputting L : 1. Wire this to the rail-carried Circuit Network.
At each station, use one wire to connect the Gate to a Decider Combinator. Gate is Open, send Red = 1. Send this to an Arithmetic Combinator, multiplying Red by -1 and outputting to L. Connect this to the shuttle rail Circuit Network. Connect this to an Arithmetic Combinator (L+0, L) and then to the Train Stop. Use the other wire, connect another Decider Combinator to the gate. Again, Gate is Open, send L = 1. Send this to the Train Stop.

In theory, the shuttle will make a circuit of all of its stops, until you get near enough to one that the Gate opens. This then turns every other stop’s Limit to 0, while leaving the one you are at, at 1. This means the shuttle will go one of two places : back to the refueling and then to you, or straight to you. Just be sure to wall off the train stop in a way that you can ride the train through the station without triggering the gate, but you can stand there waiting next to the track near enough that the gate is triggered.

Thrillho
Burner Inserter
Burner Inserter
Posts: 7
Joined: Mon Aug 09, 2021 3:22 pm
Contact:

Re: "On Demand" Train Schedule?

Post by Thrillho »

astroshak wrote:
Tue Aug 10, 2021 9:39 pm
Hmm. While I don’t think there’s a way (unless you somehow jigger it to turn signals red) to have the train use the Until Passenger Present wait condition, how’s this?

Leave the refueling station (whatever one you plan on providing it fuel at) off the circuit network, with a Train Limit of 1, so the train can always return and get topped off. Every other station that is part of the personal shuttle system, have the Train Limit dynamically set to 1. Use the Gate trigger to dynamically, using the circuit network, turn every OTHER station’s Train Limit to 0. I envision this by :

Using a Constant Combinator outputting L : 1. Wire this to the rail-carried Circuit Network.
At each station, use one wire to connect the Gate to a Decider Combinator. Gate is Open, send Red = 1. Send this to an Arithmetic Combinator, multiplying Red by -1 and outputting to L. Connect this to the shuttle rail Circuit Network. Connect this to an Arithmetic Combinator (L+0, L) and then to the Train Stop. Use the other wire, connect another Decider Combinator to the gate. Again, Gate is Open, send L = 1. Send this to the Train Stop.

In theory, the shuttle will make a circuit of all of its stops, until you get near enough to one that the Gate opens. This then turns every other stop’s Limit to 0, while leaving the one you are at, at 1. This means the shuttle will go one of two places : back to the refueling and then to you, or straight to you. Just be sure to wall off the train stop in a way that you can ride the train through the station without triggering the gate, but you can stand there waiting next to the track near enough that the gate is triggered.
Thank you Astroshak - while I wanted to avoid having the train running all the time, having a separate depot where it can stay/be fueled when not in use is a great idea.
I've been struggling with figuring out how to get the network to detect when the passenger on board is the crux of my issue.

Thrillho
Burner Inserter
Burner Inserter
Posts: 7
Joined: Mon Aug 09, 2021 3:22 pm
Contact:

Re: "On Demand" Train Schedule?

Post by Thrillho »

Actually, someone has just given me a great idea: to use a separate station on the loop effectively as a passenger detector - by having wait conditions of 'passenger present' OR 'time passed', since the train will stop there for a time if no passenger is on that can be used as the trigger to close all stations and return the train to its depot.

I'm working on a basic 'recipe' of signals now, once I've done that I'll post it and then I just have to figure out how to make it all work on the circuit network.

Thrillho
Burner Inserter
Burner Inserter
Posts: 7
Joined: Mon Aug 09, 2021 3:22 pm
Contact:

Re: "On Demand" Train Schedule?

Post by Thrillho »

So I've come up with a "basic" outline of what I'm trying to accomplish, and right now I'm messing around with the circuit network to see if I can accomplish it. I'm not that familiar with some circuit techniques though so I'm having to learn as I go - mainly I'm trying to figure out how to get one signal to turn off another. Anyway:
WORDS WORDS
So that's as far as I'm at right now.

astroshak
Filter Inserter
Filter Inserter
Posts: 597
Joined: Thu May 10, 2018 9:59 am
Contact:

Re: "On Demand" Train Schedule?

Post by astroshak »

If you have things set to enable when a C signal (for example) is 1 … you can either add -1 to the C signal, or multiply the C signal by 0, to get it to 0. A 0 signal does not actually have a value of 0; it has a “null” value instead and is ignored. Anything set to Enable when C = 1, or C > 0, will be disabled by this nullification.

Thrillho
Burner Inserter
Burner Inserter
Posts: 7
Joined: Mon Aug 09, 2021 3:22 pm
Contact:

Re: "On Demand" Train Schedule?

Post by Thrillho »

I got it working! I think. It ended up that I didn't need the 'G' signal, just the 'A' signal on two different circuits (one local to the station, one throughout the whole network that only activates when the train pulls up at a station) did the trick.
To be honest, I'm not entirely sure how I got it to work - I tried a bunch of different setups and I feel like I arrived at it mostly by trial and error - but it works! And it's scalable too.
screenshot
You trigger the train to arrive by standing next to the gate so the yellow light comes on, until the light by the station turns green; then you stay on until you're where you need to be after which, you hop off; and after passing the detector gate it returns to the depot.
After getting it this far, my only thought is that I might want to put more of the detector stations in - otherwise the train will do most of the loop before returning, though that's not the worst thing in the world. Here's the blueprint string!
BP String

Thrillho
Burner Inserter
Burner Inserter
Posts: 7
Joined: Mon Aug 09, 2021 3:22 pm
Contact:

Re: "On Demand" Train Schedule?

Post by Thrillho »

astroshak wrote:
Thu Aug 12, 2021 3:45 pm
If you have things set to enable when a C signal (for example) is 1 … you can either add -1 to the C signal, or multiply the C signal by 0, to get it to 0. A 0 signal does not actually have a value of 0; it has a “null” value instead and is ignored. Anything set to Enable when C = 1, or C > 0, will be disabled by this nullification.
Huh - I can't believe I didn't think of this. I feel like I kind of know what I'm doing when it comes to decider combinators now, but arithmetic ones befuddle me a bit. Thanks!

Post Reply

Return to “Gameplay Help”