Page 1 of 1

number of item stacks in a chest

Posted: Thu Nov 07, 2019 4:53 pm
by ichVII
With the help of my mod "Utility Combinators+", an extension to justarandomgeeks "Utility Combinators", I created a circuit, that can calculate exactly how many stacks of each item a chest contains, assuming there is no more then one incomplete stack per resource.

Just ignore the nuclear artillery in the image, it is completely insignificant and not dangerous.

Image


Re: number of item stacks in a chest

Posted: Thu Nov 07, 2019 6:41 pm
by Honktown
Neat. I hate to ask, how does it work with modded stack sizes?

Re: number of item stacks in a chest

Posted: Thu Nov 07, 2019 7:43 pm
by ichVII
My mod checks the stack size of each item prototype on init. If the stack size of an item agrees with the one given in that item prototype, it works. I assume that is always the case, but I am inexperienced with factorio modding.

But it only works correctly if the stack size is a divisor of 100k and will get into problems if it counts more then 20k stacks due to integer overflow.

It is not very hard to change that 100k to another constant, but the 20k will be replaced by maxint divided by that constant.

Re: number of item stacks in a chest

Posted: Mon Nov 11, 2019 11:45 am
by mrvn
I assume you multiply by 100k / stack size of each item.

How do you generate the signal for that? Do you have to pick the items you want to compute or did you get around the limit of 18 (iirc) signals per constant combinator?

Re: number of item stacks in a chest

Posted: Mon Nov 11, 2019 6:25 pm
by ichVII
I add stack size-1 first in order to get the correct rounding. Then I indeed multiply by 100k/stack size. The item_slot_count of an entity of the type constant-combinator can be set to any number. 18 is the default value for the constant combinator. My mod "Utility Combinators+" https://mods.factorio.com/mod/utility-combinators-plus provides a "Large Combinator" with 1k slots and the preset Combinators needed for the creation.

Re: number of item stacks in a chest

Posted: Thu Nov 14, 2019 10:48 am
by mrvn
ichVII wrote:
Mon Nov 11, 2019 6:25 pm
I add stack size-1 first in order to get the correct rounding. Then I indeed multiply by 100k/stack size. The item_slot_count of an entity of the type constant-combinator can be set to any number. 18 is the default value for the constant combinator. My mod "Utility Combinators+" https://mods.factorio.com/mod/utility-combinators-plus provides a "Large Combinator" with 1k slots and the preset Combinators needed for the creation.
I seem to remember reading that the number of signals are limited in some factorissimo thread. But maybe they fixed that since then.

Nice work.