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.
LuaInventory return number of filtered slots
Re: LuaInventory return number of filtered 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.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.
If you want to get ahold of me I'm almost always on Discord.
Re: LuaInventory return number of filtered slots
If you do it internally already please make it also available through the api.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.
My Mods: mods.factorio.com
Re: LuaInventory return number of filtered slots
It is: can_insert already checks filtered slots.Optera wrote:If you do it internally already please make it also available through the api.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 want to get ahold of me I'm almost always on Discord.
Re: LuaInventory return number of 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.Rseding91 wrote:It is: can_insert already checks filtered slots.Optera wrote:If you do it internally already please make it also available through the api.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.
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.
My Mods: mods.factorio.com