Container Entities: More inventory control

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
UberWaffe
Fast Inserter
Fast Inserter
Posts: 202
Joined: Mon May 04, 2015 4:53 am
Contact:

Container Entities: More inventory control

Post by UberWaffe »

Similar ideas already mentioned here https://forums.factorio.com/forum/vie ... 772#p78772 by @Factoruser.

Currently container entities have a property

Code: Select all

inventory_size
that determines how many 'slots' the container has.

Proposed is that it is expanded in the following fashion:

Code: Select all

intentory =
    {
      slots = 16,
      stack_size_multiplier = 1.0,
      filterable = false,
      allowed_item_category_list: [*]
    }
  • slots: The size value. (I.e. the number of slots for item stacks the inventory has). Default = 16?
  • stack_size_multiplier: The multiplier to the maximum stack size of item stacks placed in this container. (I.e. iron ore normally stacks to 50. So a stack multipier of 2.0 will mean that it can stack to 100 in this container.). Only applies to item stacks with a stack size of at least 2 or more. Default = 1.0 (Values less than 1 will never reduce the stack size to less than 1).
  • filterable: True = can apply filters to each item stack slot. (As cargo wagons currently can). Default = false
  • allowed_item_category_list: A list of item categories. Only items belonging to a category listed here can be inserted into this container. Applies before user filtering. Default: [ * ] (special wildcard meaning all categories).
If implemented, this should apply to all types of containers (chests, trains, vehicles, logistics storage, etc.)

= Use cases =
- slots -
Used in vanilla. The need for slots is obvious, as that is what exists currently as inventory_size.

- filterable -
Used in vanilla (for vehicles only). Filterable would simply be a very convenient option for mods to add in more advanced / specialist storage.
Used in some mods that currently hack in cargo wagons as filterable chests. Forced to use lua to hack around the limitation.

- stack_size_multiplier -
Unused currently, but the compression chest mod does something very similar (although with the additional addition of energy_cost_per_item_moved.)
Would be very useful for mods that want to add warehousing type storage.
Personal tests on containers revealed that (currently) extremely large inventory_size values (>1000) can cause lag when items are being inserted / removed. (I assume because the code has to look for the first empty slot / slot with items in).

Could be helpful for use in rockets, where the amount of 'something' being launched into space on a single rocket might want to be less (or perhaps more?) than the default stack size.
(Example: If satellites could stack to more than 1, the rocket inventory could use this to still only allow 1 satellite to be inserted, regardless.)

- allowed_item_category_list -
Suggested because I've seen several mods around that implement various forms of specialized storage, for both vehicles and stationary storage. (Example: Ore only storage.)

Could also be useful in vanilla to restrict rocket cargo to only allow satellites (and later on the other specific launchable items).

Rseding91
Factorio Staff
Factorio Staff
Posts: 13232
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Container Entities: More inventory control

Post by Rseding91 »

Interesting suggestion. Well written to :) It's more of a suggestion and not a mod interface request though.

This would actually be feasible for the most part. A lot of the GUIs that handle inventories would need to be updated to handle filtering correctly as well as the can-inserters for those entities.

What performance issues did you experience with the large inventories? The visual interface lagging or through code (inventory.insert) ?

However, this large of a change would need review and approval by Kovarex and Tomas as it would change a large part of how the game mechanics operate :)
If you want to get ahold of me I'm almost always on Discord.

UberWaffe
Fast Inserter
Fast Inserter
Posts: 202
Joined: Mon May 04, 2015 4:53 am
Contact:

Re: Container Entities: More inventory control

Post by UberWaffe »

Rseding91 wrote:Interesting suggestion. Well written to :) It's more of a suggestion and not a mod interface request though.
I was a bit unsure, but ended up posting here given that I wasn't asking for any new entities or content, just engine functionality.
Rseding91 wrote:What performance issues did you experience with the large inventories? The visual interface lagging or through code (inventory.insert) ?
I had modded in a warehouse object (a 4x4 chest with 1024 slots).
I had a setup where multiple inserters were pulling items (iron ore) off a belt and putting it into a warehouse.
A second set of 4 inserters were pulling items from warehouse 1 and placing it into warehouse 2.
Once warehouse 2 started filling up, I experienced significant lag (FPS < 15) while the system was running.
The statistics showed that entity updates were the culprits.
(I assume it is because it has to scan through large amounts of slots, determine they are full, and carry on before it finds the warehouse is 'full up' or finds a slot that can accept the item.)

To be honest, I'd much rather have a warehouse storage that only has a single item slot, but has a stack_size_multiplier of 1000 or something similar.
(So that you can only store one type of item in it at a time, but store lots and lots of it.)
Hence this request.

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Container Entities: More inventory control

Post by orzelek »

This would be cool to have - would make some things like item sorting much easier.
Also stack multipliers would be useful - large inventories get problematic with UI interface. They could be smaller in size but still have same amount of materials.

judos
Filter Inserter
Filter Inserter
Posts: 266
Joined: Mon Dec 08, 2014 11:17 am
Contact:

Re: Container Entities: More inventory control

Post by judos »

I also like the general idea.
Currently I need the possibilty to add items into the ingredient slots in an assembling machine. This would be useful for my packager machine which collects items directly from the belts and puts them into boxes.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13232
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Container Entities: More inventory control

Post by Rseding91 »

judos wrote:I also like the general idea.
Currently I need the possibilty to add items into the ingredient slots in an assembling machine. This would be useful for my packager machine which collects items directly from the belts and puts them into boxes.
You can already do that. The entire inventory of an assembling machine is full read/write.
If you want to get ahold of me I'm almost always on Discord.

judos
Filter Inserter
Filter Inserter
Posts: 266
Joined: Mon Dec 08, 2014 11:17 am
Contact:

Re: Container Entities: More inventory control

Post by judos »

Rseding91 wrote: You can already do that. The entire inventory of an assembling machine is full read/write.
Well then I overlooked something :shock:

/edit: Ok I found out by looking at it again. There is the get_inventory() method for entities (which is not documented on the wiki) and then for some reason the assembling machines don't contain an inventory for index 1. So in the end this works:
game.player.print(game.player.selected.get_inventory(2)[1].name)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13232
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Container Entities: More inventory control

Post by Rseding91 »

judos wrote:
Rseding91 wrote: You can already do that. The entire inventory of an assembling machine is full read/write.
Well then I overlooked something :shock:

/edit: Ok I found out by looking at it again. There is the get_inventory() method for entities (which is not documented on the wiki) and then for some reason the assembling machines don't contain an inventory for index 1. So in the end this works:
game.player.print(game.player.selected.get_inventory(2)[1].name)

Code: Select all

selected.get_inventory(defines.inventory.assembling_machine_input)
Also:
  • defines.inventory.assembling_machine_input
  • defines.inventory.assembling_machine_output
  • defines.inventory.assembling_machine_modules
Add: require "defines" to your control.lua to use them.

Edit: as for the wiki - fixed.
If you want to get ahold of me I'm almost always on Discord.

judos
Filter Inserter
Filter Inserter
Posts: 266
Joined: Mon Dec 08, 2014 11:17 am
Contact:

Re: Container Entities: More inventory control

Post by judos »

nice :) thanks a lot!

As for the wiki: https://forums.factorio.com/wiki/inde ... oryIndexes, it's not mentioned how to actually use the index. There should maybe also be a page about all the defines.

Post Reply

Return to “Modding interface requests”