Item Handler
High-level API
Device name:
item_handlerProvided by any inventory connected through a bus interface, such as a chest. To move items between inventories, use a transposer.
With several inventories connected,
find may return any of them. To grab a specific one, give the bus interface in front of the one you want a name with a wrench, and find it by that name instead.Methods
getItemSlotCount():numberGets how many slots the inventory has.
- Returns the number of slots.
getItemSlotLimit(slot:number):numberGets how many items the specified slot can hold.
-
slot: the number of the slot to look at.- Returns the most items the slot takes.
getItemStackInSlot(slot:number):tableGets what is in the specified slot.
-
slot: the number of the slot to look at.- Returns a table with the item information. Returns nothing for an empty slot.
Mid-level API
Device name:
ITEMSEach inventory is listed separately. When several are connected, label the bus interface and pass both the label and
ITEMS to OCFIND, or check what DEVS lists.Item ids are two bytes, low byte first; [
SYSTEM](system.md) provides name lookup. An empty slot reads as item 0.Methods
1 getItemSlotCountReads how many slots the inventory has.
- Returns one byte, the slot count, at most 255.
2 getItemSlotsReads a run of slots in one call.
Ask for 1 to 64 slots; more than that fails with
OCEARG, since the reply would not fit. Reading stops at the end of the inventory, so asking for 64 slots starting at 0 gives you as many as there are. Damage is in [0, 255], where 0 means undamaged, or an item that does not take damage at all, and 255 means about to break.- Takes two bytes, the slot to start at and how many slots to read.
- Returns four bytes per slot: the item as two bytes, the number of items up to 255, and damage.
3 getItemSlotLimitReads how much the slot can hold.
- Takes one byte, the slot.
- Returns one byte, the limit, at most 255.