Page 1 of 1

entity.get_inventories()

Posted: Sun Jan 29, 2023 10:06 am
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.

Re: entity.get_inventories()

Posted: Sun Jan 29, 2023 5:08 pm
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

Re: entity.get_inventories()

Posted: Mon Jan 30, 2023 11:24 pm
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.

Re: entity.get_inventories()

Posted: Tue Jan 31, 2023 12:08 pm
by ILLISIS
thank you sir that will help!