inventory

Methods for interacting with inventories.

size()Get the size of this inventory.
list()List all items in this inventory.
getItemDetail(slot)Get detailed information about an item.
pushItems(toName, fromSlot [, limit [, toSlot]])Push items from one inventory to another connected one.
pullItems(fromName, fromSlot [, limit [, toSlot]])Pull items from a connected inventory into this one.
size()Source

Get the size of this inventory.

Returns

  1. number The number of slots in this inventory.
list()Source

List all items in this inventory. This returns a table, with an entry for each slot.

Each item in the inventory is represented by a table containing some basic information, much like turtle.getItemDetail includes. More information can be fetched with getItemDetail.

The returned table is sparse, and so empty slots will be nil - it is recommended to loop over using pairs rather than ipairs.

Returns

  1. { table | nil... } All items in this inventory.
getItemDetail(slot)Source

Get detailed information about an item.

Parameters

  1. slot number The slot to get information about.

Returns

  1. table Information about the item in this slot, or nil if not present.

Throws

  • If the slot is out of range.

pushItems(toName, fromSlot [, limit [, toSlot]])Source

Push items from one inventory to another connected one.

This allows you to push an item in an inventory to another inventory on the same wired network. Both inventories must attached to wired modems which are connected via a cable.

Parameters

  1. toName string

    The name of the peripheral/inventory to push to. This is the string given to peripheral.wrap,

                 and displayed by the wired modem.
  2. fromSlot number The slot in the current inventory to move items to.
  3. limit? number The maximum number of items to move. Defaults to the current stack limit.
  4. toSlot? number The slot in the target inventory to move to. If not given, the item will be inserted into any slot.

Returns

  1. number The number of transferred items.

Throws

  • If the peripheral to transfer to doesn't exist or isn't an inventory.

  • If either source or destination slot is out of range.

Usage

See also

pullItems(fromName, fromSlot [, limit [, toSlot]])Source

Pull items from a connected inventory into this one.

This allows you to transfer items between inventories on the same wired network. Both this and the source inventory must attached to wired modems which are connected via a cable.

Parameters

  1. fromName string

    The name of the peripheral/inventory to pull from. This is the string given to peripheral.wrap,

                 and displayed by the wired modem.
  2. fromSlot number The slot in the source inventory to move items from.
  3. limit? number The maximum number of items to move. Defaults to the current stack limit.
  4. toSlot? number The slot in current inventory to move to. If not given, the item will be inserted into any slot.

Returns

  1. number The number of transferred items.

Throws

  • If the peripheral to transfer to doesn't exist or isn't an inventory.

  • If either source or destination slot is out of range.

Usage

See also