Stack Combinator

by modo_lv

An arithmetic combinator that performs stack size multiplication/division/rounding on item signals. Features signal inversion and output display, compatible with Picker Dollies and Nullius.

Content
5 months ago
1.1
17.5K
Circuit network

g [ ℹ️ ] LTN Combinator v. Stack Combinator overhead?

1 year, 1 month ago

I’m noticing at the gigabase level that stack combinator is using a ton more update time than LTN combinator but both are doing stack size operations. Is it easy to explain why these two circuit network entities are doing similar operations but seem to have very different overhead costs? I really enjoy using stack combinator to manage my inventories!

1 year, 1 month ago

Calculating the stack sizes isn't the problem, the problem it outputting the calculated result into a circuit network. It requires a second, hidden constant combinator and a script that manually sets the output signals based on the inputs (as far as I know, there is no other way to output multiple signals with arbitrary amounts). LTN Combinator does not do that. It can also afford slower updates, since it usually won't matter if a train starts moving a second or two after it should, but circuit networks connected to belts & inserters might cause issues if the signal updates are delayed.

1 year, 1 month ago

Ah that’s good to know thanks! I’ve been able to alleviate my issues by adjusting the updates per tick. I use several dozens or probably in the hundreds of tiny grid nodes on a LTN network with stack combinators and crafting combinators to produce multiple goods per stop so the overhead adds up pretty quickly. Thanks for the explanation and this awesome mod!

9 months ago

i wonder how the performance of doing it all in lua compares to using lua to maintain a hidden set of combinators which are hardcoded with the stack sizes & other details necessary to compute rounding, inversion, etc (that's a thing that mods can do, right? i'm like 99% sure it is)

if the lua acts every {longer} ticks to update this set of combinators, the performance might be good for sets of signals whose values change much more frequently than their types and would certainly be very good for small sets of signals like this

9 months ago

People have suggested this approach before, and I'm not against it in principle, but I don't feel up to writing code for managing hundreds, maybe even thousands (when huge modpacks are used) of arithmetic combinators for every single StaCo, which would also need to be correctly updated on every game load (as items and their stack sizes can change with mod updates, and sometimes just modifying mod files locally). There's also no native combinator that can do rounding operations (beyond basic division, which always rounds towards zero), so to implement those, the amount of hidden combinators would have to double or even triple.

Compakt circuit driver for stack combinator seems to be doing something like it based on its description, but I have not looked into so I don't know exactly how it handles all the details.