### list() Source: https://tweaked.cc/generic_peripheral/inventory.html Lists all items currently stored in the inventory, returning a table of item data indexed by slot. ```APIDOC ## list() ### Description List all items in this inventory. This returns a table, with an entry for each slot. ### Returns - **table | nil** - Basic information about all items in this inventory. ``` -------------------------------- ### Transfer items between inventories with Lua Source: https://tweaked.cc/generic_peripheral/inventory.html Move items from one wrapped peripheral to another using pushItems. ```lua local chest_a = peripheral.wrap("minecraft:chest_0") local chest_b = peripheral.wrap("minecraft:chest_1") chest_a.pushItems(peripheral.getName(chest_b), 1) ``` -------------------------------- ### Transfer items between chests using pullItems Source: https://tweaked.cc/generic_peripheral/inventory.html Demonstrates wrapping two chest peripherals and pulling an item from one into the other. ```lua local chest_a = peripheral.wrap("minecraft:chest_0") local chest_b = peripheral.wrap("minecraft:chest_1") chest_a.pullItems(peripheral.getName(chest_b), 1) ``` -------------------------------- ### Calculate total inventory capacity with Lua Source: https://tweaked.cc/generic_peripheral/inventory.html Sum the maximum item limits across all slots in an inventory. ```lua local chest = peripheral.find("minecraft:chest") local total = 0 for i = 1, chest.size() do total = total + chest.getItemLimit(i) end print(total) ``` -------------------------------- ### size() Source: https://tweaked.cc/generic_peripheral/inventory.html Returns the total number of slots available in the inventory. ```APIDOC ## size() ### Description Get the size of this inventory. ### Returns - **number** - The number of slots in this inventory. ``` -------------------------------- ### pushItems(toName, fromSlot [, limit [, toSlot]]) Source: https://tweaked.cc/generic_peripheral/inventory.html Transfers items from the current inventory to another inventory on the same wired network. ```APIDOC ## pushItems(toName, fromSlot [, limit [, toSlot]]) ### Description Push items from one inventory to another connected one. ### Parameters - **toName** (string) - Required - The name of the peripheral/inventory to push to. - **fromSlot** (number) - Required - The slot in the current inventory to move items from. - **limit** (number) - Optional - The maximum number of items to move. - **toSlot** (number) - Optional - The slot in the target inventory to move to. ### Returns - **number** - The number of transferred items. ``` -------------------------------- ### Retrieve item details with Lua Source: https://tweaked.cc/generic_peripheral/inventory.html Fetch detailed information about an item in a specific slot, including display name and damage values. ```lua local chest = peripheral.find("minecraft:chest") local item = chest.getItemDetail(1) if not item then print("No item") return end print(("%s (%s)"):format(item.displayName, item.name)) print(("Count: %d/%d"):format(item.count, item.maxCount)) if item.damage then print(("Damage: %d/%d"):format(item.damage, item.maxDamage)) end ``` -------------------------------- ### List inventory contents with Lua Source: https://tweaked.cc/generic_peripheral/inventory.html Iterate over an adjacent chest's inventory using pairs to handle the sparse table returned by list(). ```lua local chest = peripheral.find("minecraft:chest") for slot, item in pairs(chest.list()) do print(("%d x %s in slot %d"):format(item.count, item.name, slot)) end ``` -------------------------------- ### getItemLimit(slot) Source: https://tweaked.cc/generic_peripheral/inventory.html Returns the maximum stack size allowed for a specific slot. ```APIDOC ## getItemLimit(slot) ### Description Get the maximum number of items which can be stored in this slot. ### Parameters - **slot** (number) - Required - The slot to check. ### Returns - **number** - The maximum number of items in this slot. ``` -------------------------------- ### pullItems(fromName, fromSlot, limit, toSlot) Source: https://tweaked.cc/generic_peripheral/inventory.html Transfers items from a specified peripheral inventory into the current inventory. ```APIDOC ## pullItems(fromName, fromSlot, limit, toSlot) ### Description Transfers items from a specified peripheral inventory into the current inventory. ### Parameters - **fromName** (string) - Required - The name of the peripheral/inventory to pull from. - **fromSlot** (number) - Required - The slot in the source inventory to move items from. - **limit** (number) - Optional - The maximum number of items to move. Defaults to the current stack limit. - **toSlot** (number) - Optional - The slot in current inventory to move to. If not given, the item will be inserted into any slot. ### Returns - **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 Example ```lua local chest_a = peripheral.wrap("minecraft:chest_0") local chest_b = peripheral.wrap("minecraft:chest_1") chest_a.pullItems(peripheral.getName(chest_b), 1) ``` ``` -------------------------------- ### pullItems(fromName, fromSlot [, limit [, toSlot]]) Source: https://tweaked.cc/generic_peripheral/inventory.html Transfers items from a connected inventory into the current inventory. ```APIDOC ## pullItems(fromName, fromSlot [, limit [, toSlot]]) ### Description Pull items from a connected inventory into this one. ### Parameters - **fromName** (string) - Required - The name of the peripheral/inventory to pull from. - **fromSlot** (number) - Required - The slot in the source inventory to move items from. - **limit** (number) - Optional - The maximum number of items to move. - **toSlot** (number) - Optional - The slot in the current inventory to move to. ``` -------------------------------- ### getItemDetail(slot) Source: https://tweaked.cc/generic_peripheral/inventory.html Retrieves detailed information about an item in a specific slot. ```APIDOC ## getItemDetail(slot) ### Description Get detailed information about an item. ### Parameters - **slot** (number) - Required - The slot to get information about. ### Returns - **table | nil** - Information about the item in this slot, or nil if empty. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.