entity.get_inventories()

Post Reply
ILLISIS
Burner Inserter
Burner Inserter
Posts: 19
Joined: Wed Feb 09, 2022 10:49 am
Contact:

entity.get_inventories()

Post by ILLISIS »

entity.get_inventories () -- returns a list of inventory defines valid for this entity

Usually you know what inventory you want to use, but when you do not, it is a nightmare.

Ultimately something like the above or another way to find out what items and how many you will get from deconstructing an entity (including inputs, outputs, modules, fuel etc) would be helpful as there seems to a massive gap in the capability of the API trying to do so.

lyvgbfh
Fast Inserter
Fast Inserter
Posts: 165
Joined: Fri Jul 10, 2020 6:48 pm
Contact:

Re: entity.get_inventories()

Post by lyvgbfh »

It seems like it's possible to do now, though there's a bit of work involved and possibly some guessing if you want the exact name. You can find a demo here.
Script result:
Image

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

Re: entity.get_inventories()

Post by Rseding91 »

I added LuaControl::get_max_inventory_index() read for the next 1.1 release.

The way the C++ code does it is: loop from 1 to <= max and call get_inventory. If it returns non-nil you have an inventory. If it's nil you skip it and continue to the next index.
If you want to get ahold of me I'm almost always on Discord.

ILLISIS
Burner Inserter
Burner Inserter
Posts: 19
Joined: Wed Feb 09, 2022 10:49 am
Contact:

Re: entity.get_inventories()

Post by ILLISIS »

thank you sir that will help!

Post Reply

Return to “Implemented mod requests”