Appearance
sdk.inventory
Live backpack / equipped / depot / stash stacks from TContainerStorage. Gold sums gold coin (3031), platinum (3035), crystal (3043). Depot and stash return "not open" when those windows are closed.
lua
local M = require("sdk.inventory")count_of
function · count_of(stacks, item_id)
Count item_id in a plain stack list (no live inventory).
find_in
function · find_in(stacks, item_id)
First matching stack in a plain stack list.
gold_of
function · gold_of(stacks)
Gold value of a plain stack list.
Service
function · Service(opts)
Construct an inventory helper bound to optional filters.
GetService
function · GetService(opts)
Process inventory service, created on first use.
Get
function · Get()
Returns Inventory.
Returns
| Type | Summary |
|---|---|
Inventory | — |
items
method · items(self: Inventory, options?: InventoryQuery): ItemStack[], ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
options | InventoryQuery | — |
Returns
| Type | Summary |
|---|---|
ItemStack[], ErrorMessage? | — |
count
method · count(self: Inventory, item_id: ItemId): integer?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
item_id | ItemId | — |
Returns
| Type | Summary |
|---|---|
integer?, ErrorMessage? | — |
gold
method · gold(self: Inventory): integer?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Returns
| Type | Summary |
|---|---|
integer?, ErrorMessage? | — |
find
method · find(self: Inventory, item_id: ItemId): ItemStack?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
item_id | ItemId | — |
Returns
| Type | Summary |
|---|---|
ItemStack?, ErrorMessage? | — |
equipped
method · equipped(self: Inventory): table<integer, ItemStack>?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Returns
| Type | Summary |
|---|---|
table<integer, ItemStack>?, ErrorMessage? | — |
containers
method · containers(self: Inventory): ContainerId[]?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Returns
| Type | Summary |
|---|---|
ContainerId[]?, ErrorMessage? | — |
openContainers
method · openContainers(self: Inventory): ContainerView[], ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Returns
| Type | Summary |
|---|---|
ContainerView[], ErrorMessage? | — |
container
method · container(self: Inventory, id: ContainerId): ContainerView?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
id | ContainerId | — |
Returns
| Type | Summary |
|---|---|
ContainerView?, ErrorMessage? | — |
isFull
method · isFull(self: Inventory): boolean|nil, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Returns
| Type | Summary |
|---|---|
boolean|nil, ErrorMessage? | — |
move
method · move(self: Inventory, from: ItemStack|ItemLocation, to: ItemLocation, count?: integer): Result?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack|ItemLocation | — |
to | ItemLocation | — |
count | integer | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
drop
method · drop(self: Inventory, from: ItemStack|ItemLocation, count?: integer): Result?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack|ItemLocation | — |
count | integer | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
pickup
method · pickup(self: Inventory, from: ItemStack|ItemLocation, count?: integer): Result?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack|ItemLocation | — |
count | integer | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
equip
method · equip(self: Inventory, from: ItemStack): Result?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
dequip
method · dequip(self: Inventory, slot: integer|ItemStack, to?: ItemLocation): Result?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
slot | integer|ItemStack | — |
to | ItemLocation | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
close
method · close(self: Inventory, container: ContainerId): Result?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
container | ContainerId | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
useWith
method · useWith(self: Inventory, from: ItemStack, to: ItemStack): Result?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack | — |
to | ItemStack | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
open
method · open(self: Inventory, from: ItemStack): Result?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
split
method · split(self: Inventory, from: ItemStack, count: integer): Result?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack | — |
count | integer | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
containerService
method · containerService(self: Inventory, options?: ContainerServiceOptions): ContainerService?, ErrorMessage?
Live inventory reads preserve uncertainty: count/gold/find return nil plus an error when the session or layout cannot be read. Zero means a successful read found none; it never means "not available".
Parameters
| Name | Type | Summary |
|---|---|---|
options | ContainerServiceOptions | — |
Returns
| Type | Summary |
|---|---|
ContainerService?, ErrorMessage? | — |