number of item stacks in a chest

This board is to show, discuss and archive useful combinator- and logic-creations.
Smart triggering, counters and sensors, useful circuitry, switching as an art :), computers.
Please provide if possible always a blueprint of your creation.
Post Reply
ichVII
Long Handed Inserter
Long Handed Inserter
Posts: 98
Joined: Mon Feb 27, 2017 10:16 pm
Contact:

number of item stacks in a chest

Post 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


Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: number of item stacks in a chest

Post by Honktown »

Neat. I hate to ask, how does it work with modded stack sizes?
I have mods! I guess!
Link

ichVII
Long Handed Inserter
Long Handed Inserter
Posts: 98
Joined: Mon Feb 27, 2017 10:16 pm
Contact:

Re: number of item stacks in a chest

Post 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.

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: number of item stacks in a chest

Post 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?

ichVII
Long Handed Inserter
Long Handed Inserter
Posts: 98
Joined: Mon Feb 27, 2017 10:16 pm
Contact:

Re: number of item stacks in a chest

Post 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.

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: number of item stacks in a chest

Post 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.

Post Reply

Return to “Combinator Creations”