Merlin of Mines - Space Engineers

A set of useful scripts for aspiring Space Engineers!

View on GitHub

Inventory Block Handler

This block handler can be used to get information about inventories for any blocks or block groups.

Note that this block handler does not extend from Terminal Block, so this Block Handler does not have properties defined in the Reference: Terminal Block Handler.

Also note that many blocks have multiple inventories, so make sure you are querying the right inventory when looking for items/capacity.

Reference: Items

Note that “inventories” is a keyword for Block Type, not Block Group Type. This is because individual blocks often have more than 1 inventory (refineries, assemblers). If you want to get all inventories from a group of items that aren’t “Containers”, use "My Block Group" group inventories

Default Primitive Properties:

“Name” Property

Gets/Sets the name of the block for which this container belongs. Most useful for re-naming Cargo Container objects.

Print "My name is: " + "My Cargo" name

set "My Cargo" name to "My New Name"

“Show” Property

Gets/Sets whether the inventory shows up in the list of Inventories in the Terminal Menu. Note that this property affects all inventories for the block that owns this inventory.

show "My Cargo"
hide "My Secre Treasure" containers

“Limit” Property

This property returns the maximum cargo limit, in L. Note that this is a measure of Volume, not Mass.

Print "Cargo Limit: " + "My Cargo" limit

“Volume” Property

This proeptty returns the current cargo amount, in L. Note that this is a measure of Volume, not Mass.

“Ratio” Property

This property returns a value between 0 and 1 representing the % of cargo space that is currently in use.

Print "Cargo Percent used: " + "My Cargo" percent

“Weight” Property

Returns the current mass of the inventory, in Kg.

Print "Inventory Weight: " + "My Cargo" weight

“Amount” Property

This property will retrieve the amount (in units or kg) of items matching the ItemFilter attribute that are present in the given inventory/inventories.

This can be an expensive operation across a large set of inventories; be careful about trying to get inventory amounts of too many inventories in a single command. Instead, iterate through them and gradually calculate the total, if need be.

set goldAmount to the "gold ingot,gold ore" amount in the "Treasure Container"
set silverAmount to the "Treasure Container" "silver ingot, silver ore" amount
set oreAmount to the "Treasure Container" "ore" amount

Check out Items for more information on how to specify Item Filters.

“Types” Property

Gets a list of TypeIds & SubTypeIds for all items in the selected inventories. This is mostly used to get custom item TypeIds and SubTypeIds so that you can get custom item inventory amounts and transfer custom items across inventories.

The returned list will be a list of the TypeId and SubTypeId for all items in the given inventories, in the form TypeId.SubTypeId.

set myItemTypes to to "My Cargo" types

set customItemAmounts to []

for each itemType in myItemTypes
  customItemAmounts+=[itemType -> "My Cargo" itemType amount]

print "Item Types:\n" + myItemTypes joined "\n"
print "Item Amounts:\n" + customItemAmounts joined "\n"