This page contains four tables that work with a character's item containers:

  • Inventory: the main inventory (including the equipment slots at the start of the list).
  • Warehouse: the warehouse (read / count only).
  • EventInventory: the event inventory (read / count only).
  • MuunInventory: the Muun inventory (read, count, delete).

Read functions only require the character to be logged in; write functions (delete, edit) require the character to be in game (PLAYING), not inside onPlayerLogout, and the script must not be in restricted mode. The delete / edit functions return false when the character is trading or has a window open. The item tables returned by the GetItem functions have the same format as Player.GetItem (see the page Items (Item): create, drop, random bags, Gremory box).

Take the number of slots of each area from the GetSizes / GetSize functions; do not hard-code it. According to the source code, the main inventory has 12 equipment slots, the basic inventory part ends at slot 76 and there are 239 slots in total; the Muun inventory has 3 worn slots and 103 slots in total.

Inventory (main inventory)

Inventory.GetSizes

Returns the sizes of the areas of the main inventory.

Inventory.GetSizes() -> wear, main, full

No parameters. Returns: 3 numbers: the number of equipment slots, the end index of the basic inventory part, the total number of slots. Short names: InventoryGetWearSize(), InventoryGetMainSize(), InventoryGetFullSize() (each returns one number).

local wear, main, full = Inventory.GetSizes()

Inventory.CountItem

Counts items by code (and level). Stackable items are counted by quantity.

Inventory.CountItem(aIndex, itemCode [, level]) -> integer
ParameterTypeDescription
aIndexintegerCharacter index
itemCodeintegerItem code (group * 512 + sequence number), 0 to 65535
levelintegerItem level to count; -1 or omitted = any level

Returns: the quantity; 0 if the parameters are wrong. Short name: InventoryGetItemCount(aIndex, item, level).

local jewels = Inventory.CountItem(aIndex, 7181)   -- Jewel of Bless (14,13)

Inventory.FreeSlots

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

Inventory.FreeSlots(aIndex) -> integer

Parameter: aIndex. Returns: the number of free slots; 0 if not valid. Short name: InventoryGetFreeSlotCount.

if Inventory.FreeSlots(aIndex) < 4 then Message.Send(aIndex, 1, "Your inventory is almost full") end

Inventory.HasSpaceForItem

Checks whether the inventory still has room to hold an item type (according to the item's size).

Inventory.HasSpaceForItem(aIndex, itemCode) -> boolean
ParameterTypeDescription
aIndexintegerCharacter index
itemCodeintegerItem code (must exist in ItemList)

Returns: true if there is room; false if there is no room or the parameters are wrong. Short name: InventoryCheckSpaceByItem (returns 1 / 0).

if not Inventory.HasSpaceForItem(aIndex, 7181) then return end

Inventory.HasSpace

Checks whether the inventory has free room for an item block of a given size.

Inventory.HasSpace(aIndex, width, height) -> boolean
ParameterTypeDescription
aIndexintegerCharacter index
widthintegerWidth, from 1 to 8
heightintegerHeight, from 1 to 8

Returns: true if there is room; false if there is no room or the parameters are out of range. Short name: InventoryCheckSpaceBySize (returns 1 / 0).

if Inventory.HasSpace(aIndex, 2, 4) then ... end   -- room for one 2x4 item

Inventory.DeleteSlot

Deletes the item in a slot (including equipment slots). If it is an equipment slot, the GameServer resends the slot, recalculates stats and updates the appearance.

Inventory.DeleteSlot(aIndex, slot) -> boolean
ParameterTypeDescription
aIndexintegerCharacter index
slotintegerSlot number, counting from 0

Returns: true if deleted; false if the slot is empty, the slot is invalid, the character is trading / has a window open, or is not eligible. Short name: InventoryDelItemIndex (returns 1 / 0).

if Player.CheckItemAction(aIndex) then Inventory.DeleteSlot(aIndex, 20) end

Inventory.DeleteItems

Deletes an exact quantity of items by code (and level). If the quantity is insufficient, nothing is deleted.

Inventory.DeleteItems(aIndex, itemCode [, level, count]) -> boolean
ParameterTypeDescription
aIndexintegerCharacter index
itemCodeintegerItem code
levelintegerLevel to delete; -1 or omitted = any level
countintegerQuantity to delete, greater than 0 (default 1)

Returns: true if the full quantity was deleted; false if the quantity is insufficient, the parameters are wrong, the character is trading or is not eligible. Short name: InventoryDelItemCount(aIndex, item, level, count) (returns 1 / 0).

if Inventory.DeleteItems(aIndex, 7181, -1, 10) then
    Coin.Add(aIndex, 100, 0, 0)
end

Inventory.SetItem

Edits the attributes of the item currently in a slot. Only the fields present in the table are changed; Index (the item type) cannot be changed. After editing, the GameServer resends the slot to the client; if it is an equipment slot, stats and appearance are recalculated.

Inventory.SetItem(aIndex, slot, fields) -> boolean
ParameterTypeDescription
aIndexintegerCharacter index
slotintegerSlot number
fieldstableThe fields to change: Level, Durability, Skill, Luck, Option, Exc, Ancient, Harmony, Option380, Sockets, SocketBonus. For the meaning and limits of each field, see the page Items (Item): create, drop, random bags, Gremory box

Returns: true if edited; false if the slot is empty, the parameters are wrong, the character is trading or is not eligible. Short name: InventorySetItemTable(aIndex, slot, t), which also accepts the old-style field names (Option1, NewOption, SetOption, JoHOption...).

Inventory.SetItem(aIndex, 20, { Level = 9, Luck = 1, Option = 4 })

Inventory.SendSlot

Resends one inventory slot to the client.

Inventory.SendSlot(aIndex, slot)
ParameterTypeDescription
aIndexintegerCharacter index
slotintegerSlot number
Inventory.SendSlot(aIndex, 20)

Inventory.SendList

Resends the entire inventory to the client.

Inventory.SendList(aIndex)

Parameter: aIndex.

Inventory.SendList(aIndex)

Inventory.ReduceDurability

Reduces the durability of the item in a slot as if it were being used.

Inventory.ReduceDurability(aIndex, slot, amount) -> boolean
ParameterTypeDescription
aIndexintegerCharacter index
slotintegerSlot number
amountnumberAmount to reduce, greater than 0 (255 at most)

Returns: true if reduced; false if the slot is empty, amount is not positive, or the character is not eligible.

Inventory.ReduceDurability(aIndex, 0, 5)

Warehouse (warehouse)

Warehouse.GetItem

Reads the item in a warehouse slot.

Warehouse.GetItem(aIndex, slot) -> table | nil
ParameterTypeDescription
aIndexintegerCharacter index
slotintegerSlot number, counting from 0 (not exceeding the number of warehouse slots)

Returns: the item table; nil if the slot is empty or the parameters are wrong.

local it = Warehouse.GetItem(aIndex, 0)

Warehouse.CountItem

Counts items in the warehouse by code (and level).

Warehouse.CountItem(aIndex, itemCode [, level]) -> integer
ParameterTypeDescription
aIndexintegerCharacter index
itemCodeintegerItem code
levelintegerLevel to count; -1 or omitted = any level

Returns: the quantity (stackable items are counted by quantity); 0 if the parameters are wrong.

local n = Warehouse.CountItem(aIndex, 7181)

EventInventory (event inventory)

EventInventory.GetSize

Returns the number of slots of the event inventory.

EventInventory.GetSize() -> integer

No parameters. Short name: EventInventoryGetFullSize.

local size = EventInventory.GetSize()

EventInventory.GetItem

Reads the item in an event inventory slot.

EventInventory.GetItem(aIndex, slot) -> table | nil
ParameterTypeDescription
aIndexintegerCharacter index
slotintegerSlot number in the event inventory

Returns: the item table; nil if the slot is empty or the parameters are wrong. Short names: EventInventoryGetItemTable(aIndex, slot) (the table also has old-style field names), EventInventoryGetItemIndex(aIndex, slot) (item code only, -1 if empty).

local it = EventInventory.GetItem(aIndex, 0)

EventInventory.CountItem

Counts items in the event inventory by code (and level).

EventInventory.CountItem(aIndex, itemCode [, level]) -> integer
ParameterTypeDescription
aIndexintegerCharacter index
itemCodeintegerItem code
levelintegerLevel to count; -1 or omitted = any level

Returns: the quantity; 0 if the parameters are wrong. Short name: EventInventoryGetItemCount.

local n = EventInventory.CountItem(aIndex, 6159)

MuunInventory (Muun inventory)

MuunInventory.GetSizes

Returns the size of the Muun inventory.

MuunInventory.GetSizes() -> wear, full

No parameters. Returns: 2 numbers: the number of worn slots and the total number of slots. Short names: MuunInventoryGetWearSize(), MuunInventoryGetFullSize().

local wear, full = MuunInventory.GetSizes()

MuunInventory.GetItem

Reads the item in a Muun inventory slot.

MuunInventory.GetItem(aIndex, slot) -> table | nil
ParameterTypeDescription
aIndexintegerCharacter index
slotintegerSlot number in the Muun inventory (including the worn slots)

Returns: the item table; nil if the slot is empty or the parameters are wrong. Short names: MuunInventoryGetItemTable (the table also has old-style field names), MuunInventoryGetItemIndex (item code only, -1 if empty).

local muun = MuunInventory.GetItem(aIndex, 0)

MuunInventory.CountItem

Counts items in the Muun inventory by code (and level).

MuunInventory.CountItem(aIndex, itemCode [, level]) -> integer
ParameterTypeDescription
aIndexintegerCharacter index
itemCodeintegerItem code
levelintegerLevel to count; -1 or omitted = any level

Returns: the quantity; 0 if the parameters are wrong. Short name: MuunInventoryGetItemCount.

local n = MuunInventory.CountItem(aIndex, 6700)

MuunInventory.DeleteSlot

Deletes the item in a slot of the Muun inventory (the inventory part only; worn slots cannot be deleted).

MuunInventory.DeleteSlot(aIndex, slot) -> boolean
ParameterTypeDescription
aIndexintegerCharacter index
slotintegerSlot number in the Muun inventory part

Returns: true if deleted and the client was notified; false if the slot is empty, the slot is outside the inventory part, the character is trading or is not eligible. Short name: MuunInventoryDelItemIndex (returns 1 / 0).

MuunInventory.DeleteSlot(aIndex, 10)