Asaduzzaman Pavel

Practical Look at My Factorio 'Auto Mall' Generator

If you’ve played Factorio into the late game, you know the "Mall" problem. You need a central place that builds everything from belt splitters to nuclear reactors, but you only want it to craft when your stock is low. Doing this manually with wires and decider combinators is a special kind of hell—especially in Factorio 2.0 with the new quality tiers.

I got tired of clicking through menus to set up "If [Iron Plate] < 500" for the hundredth time, so I wrote a Go-based generator to do it for me.

The "Negative Signal" Trick

The heart of the generator is a clever (and slightly hacky) bit of circuit logic. To identify which item needs to be crafted without the signals clashing, I assign every item a unique, highly negative value starting at -5,000,000.

itemValue := -5000000
// ... for every recipe/quality pair
itemValue -= 5000

This negative value acts as a unique ID. When the circuit network sees that your stock is low, a decider combinator outputs that specific negative ID. Because the numbers are so large and negative, they don't accidentally interfere with the actual item counts on the wire. It’s one of those "it’s stupid but it works" solutions that I’m 90% sure will break if I ever play a massive modpack like Space Exploration, but for vanilla Space Age, it’s perfect.

The 5,000 Magic Number (The Real Gripe)

...And that's my biggest gripe with my own code: that -5,000 decrement is completely arbitrary. I just picked a number that felt "big enough" to avoid collisions. If I ever have a mall with more than a few thousand recipes, I'm going to hit the 32-bit integer limit for Factorio signals and the whole thing will probably explode in a sea of overflow errors. I should have probably used a proper bitmask or a more robust ID system, but I was too busy actually playing the game to care.

Handling Factorio 2.0 Quality

One thing that did turn out well was the multi-quality support. In 2.0, an "Assembler" can produce different qualities of the same item. My generator iterates through normal, uncommon, rare, epic, and legendary and creates a separate set of conditions for each.

I used the new ConstantCombinatorSection feature, which lets a single combinator have multiple "pages" of signals. It’s a huge improvement over the old way of just having one giant list of 20 items.

// Mapping into Factorio 2.0 sections
section := blueprint.Section{
    Index: i,
    Filters: filters,
}

Why Go for This?

I could have written this in Python or even just a massive Lua script, but I chose Go because I wanted a single, fast binary that I could run from my terminal and pipe directly into a clipboard manager.

The workflow is:

  1. Run automall --quality.
  2. The Go app processes the recipe data and spits out a base64-encoded blueprint string.
  3. Paste the string into Factorio.
  4. Profit.

I assumed that parsing the Factorio blueprint format (which is just Zlib-compressed JSON) would be the hardest part, but there are already some decent Go libraries for that. The real challenge was actually the shouldIgnore logic—trying to figure out which recipes don't belong in a mall (like recycling or smelting) without hardcoding a thousand exceptions. It’s still a bit of a mess of if statements, but it’s a mess that saves me three hours of clicking every time I start a new planet.

Asaduzzaman Pavel

About the Author

Asaduzzaman Pavel is a Software Engineer who actually enjoys the friction of a well-architected system. He has over 15 years of experience building high-performance backends and infrastructure that can actually handle the real-world chaos of scale.

Currently looking for new opportunities to build something amazing.