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):tablegetStackInInternalSlot.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.FloppyDiskgetStackInInternalSlot(slot:number):tabledropIntoSlot(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]):booleantrue if at least one item was moved, false otherwise.robot.transferTo from the Robot API to do so.equip():booleantrue if the items were swapped, false otherwise. This operation usually succeeds.store(side:number, slot:number, dbAddress:string, dbSlot:number):booleanstoreInternal(slot:number, dbAddress:string, dBslot:number):booleancompareToDatabase(slot:number, dBaddress:string, dBslot:number):booleancompareStacks(side:number, slotA:number, slotB:number):booleangetSlotMaxStackSize(side:number, slot:number):numbergetSlotStackSize(side:number, slot:number):numberExample:
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 |