Skip to content

Inventory Functions

InventoryGetItemCount(aIndex, itemIndex, itemLevel)

Counts how many of a specific item (by index and level) are in the player's inventory.

  • Returns: number
local count = InventoryGetItemCount(aIndex, GET_ITEM(14, 13), 0)
LogAdd(LOG_BLUE, "Player has " .. count .. " Jewels of Bless.")

InventoryDelItemIndex(aIndex, slot)

Deletes an item from a specific inventory slot.

  • Returns: boolean
if InventoryDelItemIndex(aIndex, 12) then
    LogAdd(LOG_GREEN, "Item at slot 12 deleted.")
end

InventoryDelItemCount(aIndex, itemIndex, itemLevel, count)

Deletes up to count items of the specified type from inventory.

  • Returns: boolean
-- Remove 5 Jewels of Bless
InventoryDelItemCount(aIndex, GET_ITEM(14, 13), 0, 5)

InventoryGetFreeSlotCount(aIndex)

Returns the number of free 1x1 slots in the main inventory area.

  • Returns: number
local free = InventoryGetFreeSlotCount(aIndex)
if free < 4 then
    GCNoticeSend(aIndex, 1, "Your inventory is almost full!")
end

InventoryCheckSpaceByItem(aIndex, itemIndex)

Checks if the inventory has enough space for the given item (using its actual dimensions).

  • Returns: boolean
if not InventoryCheckSpaceByItem(aIndex, GET_ITEM(0, 18)) then
    GCNoticeSend(aIndex, 1, "Not enough inventory space.")
end

InventoryCheckSpaceBySize(aIndex, width, height)

Checks if the inventory has a free rectangular area of width x height.

  • Returns: boolean
if InventoryCheckSpaceBySize(aIndex, 2, 3) then
    LogAdd(LOG_GREEN, "2x3 space available.")
end

Inventory Transaction Functions

Available when CHARACTER_RESTORE_INFO == 0. Provide atomic inventory operations.

Function Description
gObjFixInventoryPointer(aIndex) Reset inventory pointer to primary
gObjSetInventory1Pointer(aIndex) Point to backup inventory 1
gObjSetInventory2Pointer(aIndex) Point to backup inventory 2
gObjFixEventInventoryPointer(aIndex) Reset event inventory pointer
gObjSetEventInventory1Pointer(aIndex) Point to event backup 1
gObjSetEventInventory2Pointer(aIndex) Point to event backup 2
gObjInventoryTransaction(aIndex) Begin inventory transaction
gObjInventoryCommit(aIndex) Commit transaction
gObjInventoryRollback(aIndex) Rollback transaction
gObjInventoryTransaction(aIndex)
-- ... modify inventory ...
if success then
    gObjInventoryCommit(aIndex)
else
    gObjInventoryRollback(aIndex)
end