Component name: inventory_controller
This component is provided by the inventory controller upgrade.
With this API the robot can receive additional information about items or inventories and is able to put items into and take them from specific slots.
Sides required for most operations are specified in the Sides API. If no or an invalid side is provided functions will usually throw an error. To interact with the robot's own inventory you need to use the side back
, which however makes it impossible to interact with inventories behind the robot. Robots cannot access their left or right sides. You can interact with external inventories in front of, above, or below the robot.
Callbacks:
getInventorySize(side: number): number or nil[, string]
nil
followed by a description why this function failed (usually no inventory
).getStackInSlot(side:number, slot:number):table
getStackInInternalSlot
.nil
if the slot was empty (or outside the inventory's bounds), a table otherwise with the following information about the item in that slot:insertIdsInConverters=true
in the configs, and can vary between servers!oc:item.FloppyDisk
getStackInInternalSlot(slot:number):table
dropIntoSlot(side:number, slot:number[, count:number]):boolean[, string]
true
if at least one item was moved, false
and a secondary result that describes the error otherwise.robot.transferTo
from the Robot API to do so.suckFromSlot(side:number, slot:number[, count:number]):boolean
true
if at least one item was moved, false
otherwise.robot.transferTo
from the Robot API to do so.equip():boolean
true
if the items were swapped, false
otherwise. This operation usually succeeds.store(side:number, slot:number, dbAddress:string, dbSlot:number):boolean
storeInternal(slot:number, dbAddress:string, dBslot:number):boolean
compareToDatabase(slot:number, dBaddress:string, dBslot:number):boolean
compareStacks(side:number, slotA:number, slotB:number):boolean
getSlotMaxStackSize(side:number, slot:number):number
getSlotStackSize(side:number, slot:number):number
Example:
Print meta-info about the item in the position indicated by slot
local component = require("component") local sides = require("sides") local slot = 1 local item = component.inventory_controller.getStackInInternalSlot(slot) if item then print("Item name: ", item.name) print("Item count: ", item.size) print("Item damage: ", item.damage) else print("Slot " .. slot .. " is empty") end
Components | 3D Printer - Abstract Bus - Access Point - Chunkloader - Computer - Crafting - Data Card - Database - Debug - Drone - Drive - EEPROM - Experience - Filesystem - Generator - Geolyzer - GPU - Hologram - Internet - Inventory Controller - Leash - Microcontroller - Modem - Motion Sensor - Navigation - Net Splitter - Piston - Redstone - Redstone in Motion - Robot - Screen - Sign - Tank Controller - Tractor Beam - Transposer - Tunnel - World Sensor | |
---|---|---|
Others | Component Access - Signals | |
Cross-Mod Integration | Applied Energistics |