LuaInventory return number of filtered slots

Things that we aren't going to implement
Post Reply
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2919
Joined: Sat Jun 11, 2016 6:41 am
Contact:

LuaInventory return number of filtered slots

Post by Optera »

Please add a way to quickly check the amount of filtered/blocked slots in an inventory.
Going through every single slot is very time consuming for many or very large inventories when all you need is the amount of free slots.

Example:
I want to support players using filters in Logistic Train Network. I'd have to check every slot in every wagon in every train when deciding if a train has enough cargo space.

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

Re: LuaInventory return number of filtered slots

Post by Rseding91 »

Optera wrote:Please add a way to quickly check the amount of filtered/blocked slots in an inventory.
Going through every single slot is very time consuming for many or very large inventories when all you need is the amount of free slots.
That's what the game does already every time anything interacts with a filtered inventory and one of the reasons why logistics containers don't support filters.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2919
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: LuaInventory return number of filtered slots

Post by Optera »

Rseding91 wrote: That's what the game does already every time anything interacts with a filtered inventory and one of the reasons why logistics containers don't support filters.
If you do it internally already please make it also available through the api.

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

Re: LuaInventory return number of filtered slots

Post by Rseding91 »

Optera wrote:
Rseding91 wrote: That's what the game does already every time anything interacts with a filtered inventory and one of the reasons why logistics containers don't support filters.
If you do it internally already please make it also available through the api.
It is: can_insert already checks filtered slots.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2919
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: LuaInventory return number of filtered slots

Post by Optera »

Rseding91 wrote:
Optera wrote:
Rseding91 wrote: That's what the game does already every time anything interacts with a filtered inventory and one of the reasons why logistics containers don't support filters.
If you do it internally already please make it also available through the api.
It is: can_insert already checks filtered slots.
can_insert returns bool if some items can be inserted, which is useless if i need to know exactly how much free space there is.
get_filter requires to iterate over every signle slot and check if it's nil.

If it doesn't exist internally already adding parameters to Inventory objects storing filtered, blocked and free slot indexes would simplify and increase access to specific slots removing the need to iterate over whole inventories when changing filters, which is time consuming in C and even more in lua.
This information should be passed through the api as well.

Post Reply

Return to “Won't implement”