Skip to content

Instantly share code, notes, and snippets.

@Dessix
Created September 4, 2022 05:17
Show Gist options
  • Save Dessix/a5fdc4ee040952ab469ae2e7bad8cd07 to your computer and use it in GitHub Desktop.
Save Dessix/a5fdc4ee040952ab469ae2e7bad8cd07 to your computer and use it in GitHub Desktop.
Generate stack size combinators for all items in Factorio
-- A tweak atop https://github.com/technicalfactorio/technicalfactorio/blob/master/combinators/generate_signal_index.lua
-- to generate stack sizes instead of unique identifiers.
-- Does not create entries for virtual signals, as they cannot be stacked.
-- Meant to be used in combination with:
-- Pairwise Multiplication: https://www.reddit.com/r/factorio/comments/pg2dai/perfect_parallel_pairwise_multiplier/
-- Pairwise Division: https://www.reddit.com/r/factorio/comments/kl31f0/pairwise_division_with_combinators/
--
-- Run this as a console command by copying starting with this slash, and pasting it into chat: /c
local map={}
local comb = game.player.selected
idx = 0
last = nil
function addSig(sig, prot)
if idx % 18 == 0 then
comb = game.player.surface.create_entity({name = "constant-combinator", position = {x=comb.position.x+1,y=comb.position.y}, force = game.forces.player})
if last ~= nil then
comb.connect_neighbour({wire = defines.wire_type.green, target_entity = last})
end
last = comb
end
comb.get_control_behavior().set_signal(idx % 18 + 1, {signal=sig, count=prot.stack_size})
idx = idx + 1
return
end
for _,p in pairs(game.item_prototypes) do
if not p.has_flag("hidden") then
addSig({name=p.name,type="item"}, p)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment