Space Engineers

Space Engineers

View Stats:
Khas Aug 2, 2019 @ 8:13pm
How to display inventory content on LCD?
I am trying to make a display that displays the content of my containers, I have searched it up so much without success
< >
Showing 1-3 of 3 comments
Mr B. (Banned) Aug 2, 2019 @ 10:05pm 
Masters LCD display 2 is one of the best and most popular
Pembroke Aug 2, 2019 @ 11:40pm 
Or did you mean that you want to make your own programmable block script that shows the items in your containers? If so, here's how you loop through them:

int ixBlock, ixInventory, ixItem; IMyInventory inventory; MyInventoryItem item; List<MyInventoryItem> lstItems; List<IMyTerminalBlock> lstBlocks = new List<IMyTerminalBlock>(); GridTerminalSystem.GetBlocks(lstBlocks); for (ixBlock = 0; ixBlock < lstBlocks.Count; ixBlock++) { if (lstBlocks[ixBlock].HasInventory) { for (ixInventory = 0; ixInventory < lstBlocks[ixBlock].InventoryCount; ixInventory++) { inventory = lstBlocks[ixBlock].GetInventory(ixInventory); lstItems = new List<MyInventoryItem>(); inventory.GetItems(lstItems); for (ixItem = 0; ixItem < lstItems.Count; ixItem++) { item = lstItems[ixItem]; // ... add code here, that is the "item" refers to a single item, so display it's name, or add its amount to some variable and show a summary at the end of your code, or whatever it is you want to do with the items... } } } }

The above loop goes through all the blocks of the grid where the programmable block is, and for all blocks that have an inventory (that HasInventory() check) i.e. are any kind of a container, goes through all the inventories of those blocks (because some blocks may have multiple inventories like for example an assembler) and for each inventory goes through all the items it contains. In the innermost loop you've access to the actual single item and can do something with it, like display its name and amount somewhere.
Last edited by Pembroke; Aug 2, 2019 @ 11:42pm
< >
Showing 1-3 of 3 comments
Per page: 1530 50

Date Posted: Aug 2, 2019 @ 8:13pm
Posts: 3