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: 53
Joined: Mon Feb 27, 2017 10:16 pm
Contact:

number of item stacks in a chest

Post by ichVII » Thu Nov 07, 2019 4:53 pm

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
Filter Inserter
Filter Inserter
Posts: 297
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: number of item stacks in a chest

Post by Honktown » Thu Nov 07, 2019 6:41 pm

Neat. I hate to ask, how does it work with modded stack sizes?

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

Re: number of item stacks in a chest

Post by ichVII » Thu Nov 07, 2019 7:43 pm

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: 3897
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: number of item stacks in a chest

Post by mrvn » Mon Nov 11, 2019 11:45 am

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: 53
Joined: Mon Feb 27, 2017 10:16 pm
Contact:

Re: number of item stacks in a chest

Post by ichVII » 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.

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

Re: number of item stacks in a chest

Post by mrvn » Thu Nov 14, 2019 10:48 am

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”

Who is online

Users browsing this forum: No registered users