factorio

Note: This post describes complex workarounds for challenges that have been addressed by quality of life features in Factorio. For a detailed look at these improvements, see my new post: A Thank You to the Factorio Devs: An End to Complex Workarounds.

Logistic Train Upgrades For Factorio v1.1

It’s been a while, folks! I can’t believe it’s been two years since my last posts. Thank you for sharing the links and for all the comments. I hope I’ve inspired you to dig deeper into circuits for factory automation and logistics.

At long last (and by popular request), I’m doing a writeup on my logistic train upgrades for Factorio v1.1, which added two massive quality-of-life features:

Mods

Since my prior blog posts, I’ve been playing a mixture of Krastorio 2 and Space Exploration, which add extreme depth and complexity to the game (to my delight and occasional frustration).

As a result, the screenshots, blueprints, and sandbox save-file below require the AAI Containers mod.

At one point, I had a completely vanilla (and less compact) version of the Factorio v1.1 circuits, which you should be able to find in the revision history of this gist.

Overview

The logistic depot consists of four main pieces:

depot and stacker

Thanks to the AAI Containers mod and Factorio v1.1, the logistic outpost is more compact and contains many features (some are the same, some are new, and some are improved):

outpost

Logistic Loading Stations

depot

The stations are greatly simplified, thanks to the Anything signal added in Factorio v1.1. This feature removes the need for an index- or max-signal-based item filter for exact insertion. I detailed the problem and prior solutions in the previous four blog posts.

Now, the circuit is a simple difference calculation, followed by an Anything output to perform exact insertion on one item type and count at a time.

The two constant combinators in the logistic modules map to two independent loading circuits in the logistic station, connected and separated by the green and red wires.

Another trick here is to use both requester and buffer chests. If stock levels run low, the system reshuffles items into the requester chests so that trains aren’t stalled waiting for the low-stock items to be returned or produced.

I keep stacking stations for each logistic train type.

Shared Trash And Storage

trash

This station is common to all trains and resets their wagons to a known-good state to prevent item fragmentation.

Factorio signals cannot differentiate between a single stack of items (e.g., { rails: 100 }) and several fragmented, partial stacks of items that total the same amount.

Logistic Outpost

outpost

The outpost may appear complex, but it’s composed of several smaller, simpler, independent circuits that work together to provide the features I’ve described. I’ll break them down layer by layer for analysis.

The Circuit Bus & Module Interface

circuit_bus

This is the connection interface between the modules and the station. It has four pairs of lamps connected by green and red wires. The station connects to the leftmost pair of lamps, and the three modules connect to the remaining pairs.

Unloader Circuit

unloader circuit

The unloader circuit subtracts the logistic module’s request signal from the station’s storage. The logistic modules are not pictured here, but you can see them in the sections above and in my prior posts. The modules put a negative request signal onto the bus, which is used by the unloader circuit.

Items with a negative quantity are turned into an item mask with each < 0 and an output of each: 1.

The train’s contents are turned into a mask with each > 0 and an output of each: 1.

When you combine these masks, you can perform a set union by checking for each = 2 and outputting each: 1.

The result sets the filter inserters’ items.

Trash Circuit

trash circuit

This circuit doubles the negative module request signal and subtracts it from the station’s storage.

The positive results are then requested by the left buffer chest for each wagon.

The right buffer chests count the number of trashed items. When the count reaches a certain threshold (e.g., T >= 200), the station calls the trash train.

Remember, you can’t set requests and count items in a chest at the same time.

To double the loading throughput, the inserters between the buffer chests are on their own smaller circuits with an each < 100 condition.

Bot Bootstrap

bot bootstrap

This circuit bootstraps the initial logistic bots from either wagon of the seed train.

Bot Loader

bot loader

A simple difference circuit reads from a combinator with the bot set-points (e.g., { logistic: 100, construction: 100 }) and subtracts the current bot counts.

The result sets the requests on the requester chest.

Combined Again And Close Up

outpost zoom

Blueprints

You can download the logistic train blueprint book here.

And a simple rail blueprint book here.

Sandbox Download

The screenshots from this post are from a sandbox world I used to demonstrate and explain the updated logistic train circuits.

You can download it here and play with it yourself.

Bugs & Feedback

Please raise an issue here for any corrections or improvements.

Update: Vanilla Blueprints & Sandbox

Vanilla blueprints can be found here and the sandbox here.

Discussion

In /r/factorio and /r/technicalfactorio.

Enjoy! 😁