Rail split: Choose direction based on cargo

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
zOldBulldog
Smart Inserter
Smart Inserter
Posts: 1161
Joined: Sat Mar 17, 2018 1:20 pm
Contact:

Rail split: Choose direction based on cargo

Post by zOldBulldog »

direction.jpg
direction.jpg (74.7 KiB) Viewed 7499 times
In the scenario of the screenshot I'd like to send the train to the right if the cargo is coal or stone, and to the left if it is iron or copper ore.

Is there a well known and efficient way of doing this? It would be even better if the train doesn't need to stop.

I would prefer a vanilla solution, but I am willing to dive into the LTN mod if that is the only good answer.

---

NOTE:

I can imagine two not-so-good solutions:

(1)
- Put a train stop (yeah, not ideal especially since this is just a waypoint and not a destination).
- Read the contents of the cargo.
- Set a value based on the direction of the cargo (maybe L or R = green).
- Store the value on some kind of circuit that will hold it long enough for the train to take the apropriate branch.
- Use the stored value to enable/disable the signals for the right/left branches.

But I don't like the idea of (1) using a train stop for the purpose as it would have to be included in the route of every train going through here, (2) researching how to do all that before I know if there already is a well known optimal solution to this problem.


(2)
I could just use specific "final station" names. But I am building based on blueprints and I will likely have more than one stop with the name used by the iron and copper cargo, and I would very much prefer keeping the copper/iron trains in the local loop only, with no risk of the pathfinder encountering a scenario where it lets them loose into the wider train network (where the coal/stone are going), delivering to another stop with the same name and never returning to their original local loop. So... that is why I asked the question above.

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

Re: Rail split: Choose direction based on cargo

Post by quyxkh »

You're into deep circuit juju and some rail network restrictions if you want to do this in vanilla, trains choose their path at dispatch or when their braking point reaches a chain signal and their current path's exit from its block is red (also, every five seconds if it's waiting for an exit).

So to get cargo-based routing you have to set up the signals so the proper path looks shortest when the train's cargo is known and the train's choosing a path, which is only at the departure station, and you have to make sure the train doesn't repath afterwards at an inopportune moment, which means replacing most chain-signaled intersections with special (and I think much bulkier) circuit-controlled versions . . . but controlling those also requires wiring signals closed, which messes with the path-selection penalties, which means you need more penalty signals at each destination to offset the ones at circuit-controlled intersections on paths to alternates ... and path penalties are _ignored_ if the penalty signal's protected block is occupied, which means that rather than having to have two sets of penalty signals at each destination (since you presumably have to eventually let a train through, just one set won't do if you have to maintain the penalties), you have to have at least three, and they have to be widely separated (since a train might already be in whatever blocks you'd otherwise use as your momentary-alternate penalty set). And I haven't really tried to build this yet, just toying with pocs of pieces of it, there's probably more. Also, you can find many posted assertions that LTN-in-vanilla isn't possible at all, so maybe there's a showstopper I haven't discovered.

Mod support for this would basically mean building your own rail-network graph, the api for finding connected rail is tedious enough that it's never floated to the top of my things-that-would-be-fun-to-build pool.

adam_bise
Filter Inserter
Filter Inserter
Posts: 346
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: Rail split: Choose direction based on cargo

Post by adam_bise »

Still not sure why you would do this, but I am going to assume the route and cargo can be known at the time of departure. But setting the direction at departure would vary if there are multiple trains or if the sequence of trains passing the intersection isn't pre-determined.

What is the maximum number of trains that will be in transit and need their route decided for a given intersection at a time?

In the case of there being more than one, are there also multiple paths the above trains could take prior to the intersection? i.e. could a situation exist where train A leaves its station first, then train B leaves its station second, and in some cases A would pass the intersection first and other cases B would pass first.

If both of the above are true, or if non cargo routed trains also pass through the same intersection, I think things will get too complicated for predicting when and in what order trains will pass through the intersection.

I also don't know a method to read a train ID or cargo for a moving train. In this case I would use an intersection stop to route traffic.

If there is only 1 active train, or if the sequence doesn't change, and if there are no non cargo-routed trains involved, you could use a circuit wait condition that also sets the direction bit into a small buffer clocked via a rail gate.

User avatar
disentius
Filter Inserter
Filter Inserter
Posts: 694
Joined: Fri May 12, 2017 3:17 pm
Contact:

Re: Rail split: Choose direction based on cargo

Post by disentius »

Risk of getting stuck seems unavoidable.
If the path you want to signal green doesn't lead to a reachable destination in the trains station list, the train will either stop with a "no path" error, or refuse to take the green signal path.
Do you have a use-case scenario?

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

Re: Rail split: Choose direction based on cargo

Post by quyxkh »

Wow, I was very wrong. Trains repath whenever they have to brake for _any_ signal, not just a chain signal. Once stopped, they'll only repath at chain signals, but before braking they'll do one repath for anything. This means you can make multi-stop stations without any chain signals at all, and that will work so long as (a) there's no congestion at the entry, so trains are moving fast enough that they have to brake before committing to their particular stop and (b) there's enough stops that if the one they picked earlier is full there's always another open one farther on down the line.

In my defense, the wiki was wrong about repathing while stopped, it said trains would repath before braking and while stopped "on a signal", and I knew they'd only repath while stopped at a chain signal, so I just ass-me'd the whole discussion was about chain signals, including the repath before braking. Wrong. I fixed the wording to say what really happens: before braking for any signal and while stopped at a chain signal. I also tested braking for station arrival (since the original wording was "when the train needs to stop" without saying why at all) and that doesn't cause a repath even if the stops are daisy-chained to allow it.

But the upshot is, you can't use wired-closed signal penalties to control Factorio's pathfinding over any distance, because trains will do a full repath every time they need to brake.

zOldBulldog
Smart Inserter
Smart Inserter
Posts: 1161
Joined: Sat Mar 17, 2018 1:20 pm
Contact:

Re: Rail split: Choose direction based on cargo

Post by zOldBulldog »

Sounds like I need to provide much more detail.

1) As this is not easy in vanilla, I am perfectly fine using the LTN or any other mod that can handle this type of routing.

2) I have a "main" rail network. This network primarily carries finished products and it is laid out in straight lines. Although I am still evolving it to streamline product flow, maintaining its design is the ultimate consideration.

3) I will have a couple of smelting facilities. The idea is to plop them with a blueprint, let bots build them, exploit the area (a thin band one or a few screens wide in map mode) and eventually remove it. I could easily have 2 or 3 of these up at one time, as I'd setup the next one when the previous one starts to slow down. The smelting facilities have an inbound ore station, and an outbound product station.

4) Oubound product trains run on the main train network.

5) Ore trains run on a local ore train network. that only goes to the ore fields and to the smelting station it services. One local ore train network for each smelter.

This is where the need for selective pathing based on train content came to play.

6) Copper and iron trains only go to the local smelter.

7) Some stone trains I'll want to send to the local smelter.

8) But other stone trains, coal trains, uranium trains, sulfuric acid trains, and my supply and pax trains need to cross the boundary into the main network. So the split that connects to the main network must exist.

The thing that has me stumped is how to prevent the iron/copper trains from deciding to go off to another smelter far away if the pathfinding goes hokey... and never come back. And as I type this I realize that such a problem applies to the stone trains that I also want to send to the local smelter.

I was thinking that routing based on cargo type might do the trick, but because of the stone (some trains staying local and others going on the network (for example to reach a mall that makes rails) I realize that this isn't going to work.

So perhaps I need to change my question to... how do I keep these trains from hitting the main network without having to use 100% unique train stop names?

---

EDIT: A picture is worth a thousand words. This screenshot might help visualize the problem.
- The main line is at the bottom.
- The mess in blue in the center is the smelter arrays.
- The train station that is starting to form in the right is the outbound station for plates, steel, etc. You can see how it connects to the main line.
- The train station to the left (under construction) is the inbound ore station.
- The ore line isn't there yet, but it will head left, parallel to the main line, a bit above that thick yellow band that heads left. It will have small stations on it to collect ore (right now I am using belts to tap nearby ore deposits, but that won't last).

So...

For those trains carrying coal (for example for the oil plants), stone for the mall, uranium to its processing plant, etc... I need to split the inbound ore rail line and connect it to the main line below... but only have those trains *I want* to go to the main line and not any train the pathfinder decides to send there because it notices a station 3 screens away just because there is one or two trains in front of it on the way to the local smelter ore station.

Does this make more sense now?
smelter.jpg
smelter.jpg (435.85 KiB) Viewed 7447 times

adam_bise
Filter Inserter
Filter Inserter
Posts: 346
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: Rail split: Choose direction based on cargo

Post by adam_bise »

Hmm, you mention a gateway between various isolated networks and your main network. Could you move this to each of your stations? Use a circuit wait condition that also decides whether to route the train to the main network, and if so closes the local station exit and opens a normally closed signal at a path to the main network. This would be much easier to figure the timing.

In this manner trains can make it back to you local networks via a one-way return rail, but can't route to the main network except through the stations at which such a decision would need to be made.

zOldBulldog
Smart Inserter
Smart Inserter
Posts: 1161
Joined: Sat Mar 17, 2018 1:20 pm
Contact:

Re: Rail split: Choose direction based on cargo

Post by zOldBulldog »

Yes, that was the "not ideal" approach I mentioned in my original post. Doable, but not great as I'd have to give all these trains a path to that station, then if the train is one that should pass... lock the state for just long enough for the locomotive to get through the signal... and then back to closed.

Man, I so wish we could name trains.

adam_bise
Filter Inserter
Filter Inserter
Posts: 346
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: Rail split: Choose direction based on cargo

Post by adam_bise »

Or a "suffix station name" checkbox in the BP.

jcranmer
Long Handed Inserter
Long Handed Inserter
Posts: 90
Joined: Wed Jun 29, 2016 9:59 pm
Contact:

Re: Rail split: Choose direction based on cargo

Post by jcranmer »

I haven't tested this, but a bullpen latch might do the trick: create a long transition track between the local network and the main network (and vice versa). Create a circuit that latches the last signal to red unless a train is present in the bullpen and that latches the first signal to red when a train is in the bullpen. If you make the bullpen long enough, the train won't have to slow down. The wiki says the pathfinding penalty is an extra 1000 tiles for a circuit-blocked signal, which is hopefully severe enough to prevent trains from traversing the bullpen unless they have to. It won't guarantee lockup-free situations, but there is some flexibility to penalize pathfinding arbitrarily bad for anyone trying to make the crossing.

A simpler option is to make transfer stations that collect the ores that need to cross to the main network that exchange from one side to the other. Another possibility (which would require a lot of effort to retrofit onto an existing network) would be to run a parallel circuit network that keeps track of what the train in the adjacent block is carrying. (It's basically building a massive latched switch register).

Bauer
Filter Inserter
Filter Inserter
Posts: 346
Joined: Fri May 05, 2017 12:48 pm
Contact:

Re: Rail split: Choose direction based on cargo

Post by Bauer »

Why do you have multiple smelters in the first place? Let's assume this is a necessity...

Since ore patches deplete and need to be rebuild and since Cu/Fe balance is difficult to achieve at the ore patch, I suggest:

Build an ore depot utilising cars. Two stations, 4 grid-blocks apart (inserter-car(2)-inserter), set the inventory of the cars to 50/50 iron-ore/copper-ore, and let the delivery trains unload until inactivity is reached. If one kind (or both) is not required the trains will return full to the ore-field, cycling merrily until the stuff they bring is needed. On the delivery side of the ore depot you have your ore-trains from the ore-field with a generic station name for ore deliveries for all ore-fields. On the supply side of the ore depot you have your ore-trains to the smelters matching the capacity of the smelters.

Besides all this, the answer is LTN. Because: There is no way to read the content of a moving train. Drawback: All trains need to have the same configuration.
I also like jcranmer's idea with the bullpen latch to separte train networks.

zOldBulldog
Smart Inserter
Smart Inserter
Posts: 1161
Joined: Sat Mar 17, 2018 1:20 pm
Contact:

Re: Rail split: Choose direction based on cargo

Post by zOldBulldog »

Summarizing options so far:

1) Train stop: On the exit branch, have a train stop before the merge into the main network. The content is evaluated,l latched, used to turn the exit signal green, and once the train starts passing it resets back to red. Disadvantages: Train has to stop. Need a stacker to support multiple trains exiting.

2) Bullpen Latch. Not sure I fully understand it, but its main advantage is that it does not require stopping.

3) Transbording. Simple and safe. Transboard on a diagonal track should allow train to train using stack inserter and be fairly quick. Disadvantage: UPS drain if there are a lot of trains Transbording (which is probably not the case).

4) Undesirable path: Easiest to build, hard to achieve.
- If the main train network is such that pathfinding cost to reach the other local ore network smelter is very high compared to even waiting at the local stacker, then those local trains will likely never exit the local loop.
- I ended up *initially+ testing this approach, given the complexity/cost of the other options. Who knows, it might even work.
- I did this by making the path from the main rail network to the smelter have to go through the full ore collection loop (the ore network at this time - and possibly always - is a single lane, one direction loop from the smelter ore station exit through the areas where I will collect ore (simple branches to ore load stations) and back to the smelter ore station entry.
- So, the hope is that the pathfinder will always find the route to a different smelter ore input stop more expensive than going to the local one even if it has to wait at the stacker.

EDIT: Screenshots.

(1) Ore rail loop (thin line on the left inside the quadrant). Once all ores are exhausted it gets dismantled.
- Notice that it goes *through* the smelter ore input station.
- The main rail line is at the bottom.
- The exit to the main line is just before the smelter ore input station's stacker.
- The entry from main line bypasses the station (goes just right of it between the station and smelters) and joins the loop right above the station. So arriving (empty) trains go straight into the ore loop. I am hoping that the length and circular nature of the local ore loop will be enough of a pathfinder penalty for trains from other local ore loops from wanting to come here. Otherwise... I will adapt to one of the other methods :)
ore rail loop.jpg
ore rail loop.jpg (541.71 KiB) Viewed 7354 times
(2) Expanded view of the lines leading out and into the ore smelter input station. This is a BIG screenshot.
smelter ore in.png
smelter ore in.png (44.89 MiB) Viewed 7354 times
In case you are wondering, yes, the train station is a hybrid that unloads from wagons but also accepts belt-fed ores. That way I initially suck local ores directly with belts, then add trains (prioritizing the belts), then I remove the belts and just rely on wagons. Lets me lay out things (and build them) once, but evolve.

Apologies for the long load screenshot. I tried to put them inline inside a spoiler tag but instead of "not loading them" it just plopped then at the bottom of the post. Either a quirk of the new forums or I am not aware of some detail needed to put an image inside a spoiler.

@Bauer:
The hope is to never need more than 2 or at most 3 smelters at one time. But there are things that might make me add the next (and eventually retire the oldest) :
- One is expansion. After the initial space clearing stage I plan to expand mining in a single direction, clearing a fairly thin band as I do. This will take me to larger deposits. Once distances grow big, it makes sense to create the next smelter further out and eventually retire the previous one. But they will coexist for a time.
- Another is larger trains. I started with 1-4-1 (same direction locos) trains and stations, although I slightly future-proofed my main line rail by supporting 1-4-2-4-1 as well. As I grow I will need to build stations (and smelters) for the larger trains. In the far future I even envision moving to much larger trains.
- Third is redesign. I am already doing this... and in this map I have not even built real volume science, production mall and much less rockets (my goals for this run are different). My initial smelter and its stations were a bit messy (but is not retired yet). This new smelter and stations are laid out better (although I am unhappy with the steel smelting design, but that can be replaced in site). The design is such that I can keep adding smelting lines and train stops as needed. And yet, I only made a 12-train stacker, so if I can't eventually redo its stackers in place, I will need to... Yep, make another smelter further out. Hopefully by then I will be close to exhausting the nearby resources and I will be ready for the next "bigger and better" smelter.

So, as you see, multiple smelters will be a natural part of evolving through the various stages of a map I plan to keep for a very long time.
Last edited by zOldBulldog on Fri Oct 05, 2018 12:53 pm, edited 2 times in total.

Bauer
Filter Inserter
Filter Inserter
Posts: 346
Joined: Fri May 05, 2017 12:48 pm
Contact:

Re: Rail split: Choose direction based on cargo

Post by Bauer »

Thanks for the explaination.
When I do a new furnace design, I build it, test it, and then switch over to it. The old one immediately turns into an industry ruin (to be demolished later by my robot force).
This, of course, requires a strictly modular base concept...

zOldBulldog
Smart Inserter
Smart Inserter
Posts: 1161
Joined: Sat Mar 17, 2018 1:20 pm
Contact:

Re: Rail split: Choose direction based on cargo

Post by zOldBulldog »

Bauer wrote:
Fri Oct 05, 2018 11:12 am
Thanks for the explaination.
When I do a new furnace design, I build it, test it, and then switch over to it. The old one immediately turns into an industry ruin (to be demolished later by my robot force).
This, of course, requires a strictly modular base concept...
Modular is exactly where I am headed, supplied by trains, along a mostly linear main rail line (yes eradicator, I am looking at you for putting that linear design in my head?!)

I expect to be a massive space user :)

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

Re: Rail split: Choose direction based on cargo

Post by quyxkh »

I think that unload-stop design runs out of steam about when you hit purple science, anyway by the time you get full stack inserters that layout's going to require about five times as many unload stops as needed, you've got six stack inserters buffering for a single red belt so each stop can stay at most 16% busy, unload-to-chest stack inserters run a 26-tick cycle, 60/26 swings per second, 12 per swing, 6 of that, ~9969 ore/min unload capacity vs 1600 belt delivery.

yup: purple science gets you stack size 6-11, and at stack size six one belt can't drain the buffers as fast as you can load them.

zOldBulldog
Smart Inserter
Smart Inserter
Posts: 1161
Joined: Sat Mar 17, 2018 1:20 pm
Contact:

Re: Rail split: Choose direction based on cargo

Post by zOldBulldog »

quyxkh wrote:
Fri Oct 05, 2018 2:33 pm
I think that unload-stop design runs out of steam about when you hit purple science, anyway by the time you get full stack inserters that layout's going to require about five times as many unload stops as needed, you've got six stack inserters buffering for a single red belt so each stop can stay at most 16% busy, unload-to-chest stack inserters run a 26-tick cycle, 60/26 swings per second, 12 per swing, 6 of that, ~9969 ore/min unload capacity vs 1600 belt delivery.

yup: purple science gets you stack size 6-11, and at stack size six one belt can't drain the buffers as fast as you can load them.
Are you talking of the transboard or the stop on the way out to the main line? If the 2nd... the stop would not be for unloads, just to check contents of the cargo.

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

Re: Rail split: Choose direction based on cargo

Post by quyxkh »

zOldBulldog wrote:
Fri Oct 05, 2018 3:27 pm
quyxkh wrote:
Fri Oct 05, 2018 2:33 pm
I think that unload-stop design runs out of steam about when you hit purple science, anyway by the time you get full stack inserters that layout's going to require about five times as many unload stops as needed, you've got six stack inserters buffering for a single red belt so each stop can stay at most 16% busy, unload-to-chest stack inserters run a 26-tick cycle, 60/26 swings per second, 12 per swing, 6 of that, ~9969 ore/min unload capacity vs 1600 belt delivery.

yup: purple science gets you stack size 6-11, and at stack size six one belt can't drain the buffers as fast as you can load them.
Are you talking of the transboard or the stop on the way out to the main line? If the 2nd... the stop would not be for unloads, just to check contents of the cargo.
Sorry, must have missed the other unload stop, I mean the unload stop in the recent "smelter ore in" picture, the one with the six-stack-inserters-to-one-red-belt setup,

zOldBulldog
Smart Inserter
Smart Inserter
Posts: 1161
Joined: Sat Mar 17, 2018 1:20 pm
Contact:

Re: Rail split: Choose direction based on cargo

Post by zOldBulldog »

quyxkh wrote:
Fri Oct 05, 2018 3:47 pm
zOldBulldog wrote:
Fri Oct 05, 2018 3:27 pm
quyxkh wrote:
Fri Oct 05, 2018 2:33 pm
I think that unload-stop design runs out of steam about when you hit purple science, anyway by the time you get full stack inserters that layout's going to require about five times as many unload stops as needed, you've got six stack inserters buffering for a single red belt so each stop can stay at most 16% busy, unload-to-chest stack inserters run a 26-tick cycle, 60/26 swings per second, 12 per swing, 6 of that, ~9969 ore/min unload capacity vs 1600 belt delivery.

yup: purple science gets you stack size 6-11, and at stack size six one belt can't drain the buffers as fast as you can load them.
Are you talking of the transboard or the stop on the way out to the main line? If the 2nd... the stop would not be for unloads, just to check contents of the cargo.
Sorry, must have missed the other unload stop, I mean the unload stop in the recent "smelter ore in" picture, the one with the six-stack-inserters-to-one-red-belt setup,
Ah OK. You are right. For starters that one needs blue belts, and even then it won't saturate them. That unload's capacity is about 1 blue belt per 2 wagons. I have other designs that can unload up to 4 blue belts per wagons that I use for better unload speeds. But those will go to the next smelter, this is pretty early in the map's lifespan and my current goal is to work out the overall map layout, not individual factories... so simple and compact works well at this stage.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1639
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Rail split: Choose direction based on cargo

Post by Pi-C »

Regarding the original question, keeping some trains on a local network while allowing others onto the global one without using a train stop to read the trains' cargo:

My main rail system is hugely inspired by Aavak's guide (starting at episode 6). He uses routing stations that differentiate between fluid and cargo wagons based on different train length (measured via the signals before and after a switch-into-nothing): fluid trains have 1 locomotive + 2 fluid wagons, cargo trains 1 locomotive + 3 cargo wagons. There are routing stations along the way where trains will be measured and their cargo (if there is any) be read to determine their route. The design relies on wiring almost all of the railway with green and red wires (for signalling what materials are required and requesting trains carrying such load). This system is almost working for me (some logic tweaking still is needed), but I find that my trains are too short to provide sufficient supply to my main base once the ore has to be brought in from patches that are farther away. One reason might be that there are too many routing stations where all trains have to stop too close together, so trains can hardly drive at maximal speed.

My new take is to have a second (more conventional) rail network where longer trains (currently I have only one 2-6-2 train set up for iron) haul in the ore from the far-away outposts and drop them off at some location served by the main rail network. The long trains are unloaded into chests, belts transport the stuff from the long-train unload to the short-train loading station. However, I also keep a small supply train (1 locomotive + 2 cargo wagons) on the outer network that has a stop at every station. I use simple signalling to direct the cargo and the supply trains to their respective stops -- which closes the circle to Aavak's system as the routing is based on train lengths:
  • The switch has two exit signals; the one on track to the supply-train stop (A) is green by default, the one to the cargo-train stop (B) is red.
  • About a long-train length before the switch, there is a signal (C) connected to A and B. The signal for the cargo train (A) is open while C is red, the signal for the supply train (B) opens if C is green.
  • Between the switch and C, there is another signal (D) placed so that C is blocked by long trains, but open if a short train has passed. D has to be close enough to the switch that the locomotive has passed A before C is green again -- this way I don't have to fiddle with memory cells which keep the state of C and have to be reset again.
The concept is really simple, and the beautiful thing is that it works without train stops (my trains wait for "Circuit condition: Green" + some time of inactivity, so not having a train stop lets the train brake at best, not stop -- and the inactivity period doesn't come into play at all). There is one drawback, though: the train lengths have to differ significantly! I got this to work for 2-6-2 vs. 1-2 trains, but I have issues with applying this system to 1-3 vs. 1-2 trains. It works if the train drives slowly. At higher speeds, however, the signals are set before the train has time to recalculate its path, so it could go to the wrong exit only to be stopped by a red signal. I recently read that just braking at a normal signal enforces calculating a new path. Perhaps I can use that somehow -- I have a vague idea of a red signal close to the switch that forces the train to brake but is opened on some circuit condition or other before the train really stops.

So, to round it up, perhaps you could consider using trains of significantly different lengths on your main network and the local ones? Of course, that wouldn't help much with your stone trains that should travel on the main network and the local ones -- unless you'd be using different-length trains for the same cargo type.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

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

Re: Rail split: Choose direction based on cargo

Post by quyxkh »

Pi-C wrote:
Tue Oct 16, 2018 2:59 pm
At higher speeds, however, the signals are set before the train has time to recalculate its path, so it could go to the wrong exit only to be stopped by a red signal.
Yep. You have to keep the train's braking point from reaching the switch exits before they're set up. It's easy-ish to do reliably, set up N+1 rail signals 7 meters apart, so for your 1-3 trains do five to count up to four, then one more 3+ meters farther along for braking-point control. Greenwire all the signals together, set the N entry signals to send C on red and the next one to send L on red, B on yellow. Set the farthest one, the braking-point-control signal, to close if B>C, so it'll close if a train has reserved the LB signal but hasn't yet reached any of the C signals.

To read the train length, you want the C signal value when the L signal lights, so run a pulse converter on L and feed everything into a memory cell on L=1, this one's setup for up to 6 carriages.
Setup to distinguish up to 6 carriages e.g. anything from a 1-1 up to a 1-5/1-4-1 train
Setup to distinguish up to 6 carriages e.g. anything from a 1-1 up to a 1-5/1-4-1 train
snap@T2827471=3408x560+620.25-57.75,z2.jpg (84.95 KiB) Viewed 7089 times


The memory cell readout's the accumulator on the right, feed that to your switch exits at least twice the braking distance you set ahead of the control signal, 1-1 nuc trains delivering nuclear fuel accelerate really really fast, so for this one that sets an at-most-46 meter braking distance on release you want the switch exits at least 46 rail segments farther along.

Post Reply

Return to “Gameplay Help”