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")Constants
Lua 5.4 has no enums — these are integer (or string) fields on the module.
| Name | Value | Summary |
|---|---|---|
STASH_STOW_ITEM | 0 | — |
STASH_STOW_CONTAINER | 1 | — |
STASH_STOW_STACK | 2 | — |
STASH_WITHDRAW | 3 | — |
count_of
function · count_of(stacks, item_id)
Sum counts for one appearance id across an already-fetched stack list. Does not touch live memory — use Inv:count when the snapshot may be stale.
find_in
function · find_in(stacks, item_id)
First stack row with this appearance id, or nil. Same snapshot contract as count_of — does not reread TContainerStorage.
convertible_coin_stack
function · convertible_coin_stack(stacks, minimum)
Pick the best backpack stack that UseObject will convert (100 gold or 100 platinum).
gold_of
function · gold_of(stacks)
Gold/platinum/crystal stacks in gp. Equipped coins (rare) are the caller's job; this only sums the list it is given.
moveObject
function · moveObject(from, to, item_id, count)
GameclientMessageMoveObject. Native move_native wins; Lua path writes from/identifier/to/count with has_bits 0x0F.
useObject
function · useObject(item_id, loc, index)
GameclientMessageUseObject. index omitted → native use_native, then has_bits 3; with index, has_bits 7 (window slot for opening a bag).
look
function · look(self: Inventory, from: ItemStack|ItemLocation): Result?, ErrorMessage?
GameclientMessageLook at a location + identifier.
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack|ItemLocation | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
pickObjectToImbue
function · pickObjectToImbue(item_id, loc, slot)
GameclientMessagePickObjectToImbue (position, identifier, shrine slot).
stash
function · stash(action, pos, item_id, stackpos, count)
GameclientMessageStashAction. action is STASH_STOW_* / WITHDRAW; position is omitted on withdraw (bits still include identifier/action/count).
equipObject
function · equipObject(item_id)
GameclientMessageEquipObject — identifier only; client chooses the slot.
closeContainer
function · closeContainer(container)
GameclientMessageCloseContainer by runtime id. Native close_native first.
upContainer
function · upContainer(container)
GameclientMessageUpContainer by runtime id (already-open nested window).
openParentContainer
function · openParentContainer()
Empty OpenParentContainer — no fields on the wire.
seekInContainer
function · seekInContainer(container, index, category)
GameclientMessageSeekInContainer. container/index/category are all required; a missing category is not a valid depot page seek.
useTwoObjects
function · useTwoObjects(from_id, from_loc, to_id, to_loc)
GameclientMessageUseTwoObjects (from ident+pos, to ident+pos).
Service
function · Service(opts)
New container_service instance (not the process singleton).
GetService
function · GetService(opts)
container_service process singleton (same as Inv:containerService).
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?
Slot-full nest: every open child is full and no closed nested bag remains. Without a nest, every open carrying bag is slot-full. Not weight.
Returns
| Type | Summary |
|---|---|
boolean|nil, ErrorMessage? | — |
lootDestination
method · lootDestination(self: Inventory, preferred?: table, exclude_container?: integer, item_id?: ItemId): ItemLocation?, ErrorMessage?
With a preferred set (loot path): nested bag with a free slot when a nest exists. preferred==nil (depot withdraw): first carrying bag with a free slot, never a nest redirect.
Parameters
| Name | Type | Summary |
|---|---|---|
preferred | table | — |
exclude_container | integer | — |
item_id | ItemId | — |
Returns
| Type | Summary |
|---|---|
ItemLocation?, 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, index?: integer): Result?, ErrorMessage?
Optional index is UseObject.index (container window).
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack | — |
index | integer | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
use
method · use(self: Inventory, from: ItemStack|ItemLocation, index?: integer): Result?, ErrorMessage?
UseObject at from (same as open).
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack|ItemLocation | — |
index | integer | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
stow
method · stow(self: Inventory, from: ItemStack|ItemLocation, count?: integer): Result?, ErrorMessage?
Stow one stack to the store inbox.
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack|ItemLocation | — |
count | integer | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
stowContainer
method · stowContainer(self: Inventory, from: ItemStack|ItemLocation): Result?, ErrorMessage?
Stow container's content.
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack|ItemLocation | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
stowStack
method · stowStack(self: Inventory, from: ItemStack|ItemLocation): Result?, ErrorMessage?
Stow the whole stack type.
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack|ItemLocation | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
retrieve
method · retrieve(self: Inventory, item_id: ItemId, count?: integer): Result?, ErrorMessage?
Withdraw from stash.
Parameters
| Name | Type | Summary |
|---|---|---|
item_id | ItemId | — |
count | integer | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
pickToImbue
method · pickToImbue(self: Inventory, from: ItemStack|ItemLocation, slot?: integer): Result?, ErrorMessage?
Pick Item for the imbuing shrine (slot = hole, default 0).
Parameters
| Name | Type | Summary |
|---|---|---|
from | ItemStack|ItemLocation | — |
slot | integer | — |
Returns
| Type | Summary |
|---|---|
Result?, ErrorMessage? | — |
changeGold
method · changeGold(self: Inventory, options?: {minimum?: 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 |
|---|---|---|
options | {minimum? | — |
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? | — |