This page documents internal-inventory inspection callbacks. They are typically exposed by the inventory_controller upgrade on robots and drones.
- Repository:
opencomputers - Typical Lua component name:
inventory_controller - Backing trait:
InventoryAnalytics
Lua-facing inventory slots are 1-based.
- Syntax:
inventory_controller.getStackInInternalSlot([slot]) - Returns:
- Success: item description table
- Failure:
nil, "not enabled in config"
- Purpose: Returns a detailed stack description for the specified internal slot, or for the selected slot if omitted.
This callback is gated by the OpenComputers item-stack inspection config option.
- Syntax:
inventory_controller.isEquivalentTo(otherSlot) - Returns:
boolean - Purpose: Checks whether the selected slot and another internal slot share at least one OreDictionary entry.
Behavior:
- Two empty slots count as equivalent.
- Empty versus non-empty counts as not equivalent.
- Syntax:
inventory_controller.storeInternal(slot, dbAddress, dbSlot) - Returns:
boolean - Purpose: Copies the selected internal stack description into a database slot.
Return value:
trueif the destination database slot already contained data.falseif the destination database slot was previously empty.
Important note:
- The implementation expects a real stack in the source slot. Empty source slots are not a valid use case.
- Invalid database addresses raise errors such as
no such componentornot a database.
- Syntax:
inventory_controller.compareToDatabase(slot, dbAddress, dbSlot[, checkNBT]) - Returns:
boolean - Purpose: Compares one internal slot against an item record stored in a database.
checkNBT defaults to false.
local component = require("component")
local robot = require("robot")
local ic = component.inventory_controller
local db = component.database
robot.select(1)
local stack, reason = ic.getStackInInternalSlot()
if stack then
print("Selected item:", stack.name, stack.size)
else
print("Inspection unavailable:", reason)
end
ic.storeInternal(1, db.address, 1)
print("Matches database slot 1:", ic.compareToDatabase(1, db.address, 1, true))
print("Equivalent to slot 2:", ic.isEquivalentTo(2))opencomputers-inventory-controlopencomputers-world-inventory-analyticsdatabase