Dynamic Rail Kilofactory

This board is to show, discuss and archive useful combinator- and logic-creations.
Smart triggering, counters and sensors, useful circuitry, switching as an art :), computers.
Please provide if possible always a blueprint of your creation.
Post Reply
Aladrius
Inserter
Inserter
Posts: 22
Joined: Thu Jun 09, 2016 12:04 pm
Contact:

Dynamic Rail Kilofactory

Post by Aladrius »

When the upcoming features for .13 were shared, I was hoping for the ability to turn rail stations "on" and "off" via circuit network input. It came close with the rail signal control, not quite what I had hoped for. So, I set out and wrote a small mod to get something similar to what I had in mind. By changing the station name based on circuit network input, I got the behavior I was looking for.

Here's a link to the mod:
https://mods.factorio.com/mods/Aladrius ... train-stop

I'm in the process of building up a moderate sized rail network factory. The key behavior that the mod allows is a train or group of trains to dynamically service 1:N stations with some simple combinator setups determining if a station has items to export, or needs items imported. Notably, this doesn't require running wires between each station in the system, as they 'communicate' via the station names. I'll share my oil system as an example.

Here's a sample station set up at an oil field:
Image

The oil waiting to be barreled is stored in tanks, so the first task is to figure out how many empty barrels we need for it. We take the oil on hand, divide by -25, this gives us -1 * barrels we need.
Image

We'll use that to drive our stack filter inserter until it's moved enough barrels to match demand:
Image

So far, we're not doing anything that's not available or applicable to vanilla Factorio. This next step is where the mod comes in. We're only going to call for a train once we've got at least 100 barrels worth of oil waiting in those tanks. A single train car can hold 400 barrels worth, so as my factory expands and I have more fields to service, I'll raise this number to 200 or more. "Calling" the train is accomplished by sending the station a Green color signal. It will then set its name to OilPump|Green -- the portion of the name after the | is the part set by the mod. The logic follows the lamp coloring, so it's a simple thing to wire an indicator next to it to visually show the state of the station.
Image

The train's schedule is very simple. It travels between the refinery, and OilPump|Green. If no stations have 100 or more barrels of oil waiting in tanks, it'll just sit at the refinery until a pumping station is ready, and changes its name to OilPump|Green. That's currently the case in the screenshot. No station has the name OilPump|Green, so the train acts like it's been picked up or destroyed and ignores the station until something with that name appears.
It takes about 10 seconds to transact all the full/empty barrels at a remote station. 15 seconds should be plenty. There are some more complicated setups that let you manage your station dwell times more precisely, but this is good enough for now and keeps the stations simple.
Image

On the first visit to a new station, the train will drop off ~100 barrels, and probably leave with a handful of full barrels that happened to get barreled while it was there. On the 2nd and all future visits, it will drop off ~100 empty barrels, and pick up ~100 full barrels. The bulk of the oil barreling happens while the train elsewhere, so one train can service many remote stations.

The Refinery Station setup is pretty basic, not much going on here:

Image

Just a balanced inserter setup keeping the barrels distributed between three chests each for full/empty barrels for quick transactions. Takes about 5 seconds to load/unload on this side. Potentially, as my factory grows, I could have multiple refineries that request trains by setting their name depending on their on hand quantity of oil or full barrels. For now, one central collection point is meeting my needs. It's only a kilofactory after all, nothing mega yet.

Currently a single 1:1 train is keeping up handily with 6 remote oil fields, probably can scale to 10-12 stations without a problem just by increasing the threshold for the train to visit so that it'll be transacting 200+ barrels each time instead of 100. Beyond that, adding a additional 1:1 trains with the same schedule will add more capacity as well.

Below is a shot of iron smelting. For Iron, I'm using dynamic stations both on the supply and demand side. Mines call for trains based on the amount of ore on hand, and the smelting drop off stations open or close themselves based on the amount of ore waiting to be processed. Each drop station feeds a block of 96 smelters, and delivers to more dynamic stations off the screen to the right. Those advertise themselves as available as long as they have at least 4k (one carload) of plates ready.

Image

All in all, this factory is working as I hoped: I'm getting more intelligent on demand train use, and retaining a mostly vanilla feel. Thanks for reading this far. If there's interest, I'll post more pictures and detailed writeups of the iron/copper operations and other uses for the mod.

Post Reply

Return to “Combinator Creations”