The functions on this page read item type data from the server's ItemList, without needing a character. All of them take itemCode, the item code (group * 512 + sequence number, from 0 to 65535). If the code does not exist, the function returns the default value stated for each function.
Common parameter:
| Parameter | Type | Description |
|---|---|---|
itemCode | integer | Item code |
Item.IsValid
Checks whether the item code exists in ItemList.
Item.IsValid(itemCode) -> boolean
Returns: true if it exists. Short name: IsItem (returns 1 / 0).
if not Item.IsValid(code) then Log.AddC(1, "Wrong item code " .. code) end
Item.GetName
Returns the item name.
Item.GetName(itemCode) -> string
Returns: the item name; an empty string if the code does not exist.
Message.Send(aIndex, 1, "You received " .. Item.GetName(code))
Item.GetKindA
Returns the item's type group A (Kind1).
Item.GetKindA(itemCode) -> integer
Returns: the group A code; 0 if the code does not exist. Short name: GetItemKindA.
The value comes from the item's KindA column in the server's ItemList.xml, so the meaning of each number is determined by the classification table in that file (look it up in that file; there is no fixed table in the script). Examples GameServer uses: KindA 45 - 49 and 56 are Legendary items.
local kind = Item.GetKindA(code)
Item.GetKindB
Returns the item's type group B (Kind2).
Item.GetKindB(itemCode) -> integer
Returns: the group B code; 0 if the code does not exist.
The value comes from the item's KindB column in ItemList.xml (look up that file for the meaning of each number). Examples GameServer uses: KindB 60 is the Conqueror wing, 76 is the 4th-level wing, 106 is the 5th-level wing.
local kind = Item.GetKindB(code)
Item.GetSize
Returns the size (number of cells) the item occupies in the inventory.
Item.GetSize(itemCode) -> width, height
Returns: 2 numbers: the width and the height; 0, 0 if the code does not exist.
local w, h = Item.GetSize(code)
if Inventory.HasSpace(aIndex, w, h) then ... end
Item.IsSocket
Checks whether the item is a type that can have socket slots.
Item.IsSocket(itemCode) -> boolean
Returns: true if it is a socket item. Short name: IsSocketItem (returns 1 / 0).
if Item.IsSocket(code) then ... end
Item.IsExcSocketAccessory
Checks whether the item is a socket accessory (a pendant or ring of the socket type).
Item.IsExcSocketAccessory(itemCode) -> boolean
Returns: true if it is a socket pendant / ring.
local acc = Item.IsExcSocketAccessory(code)
Item.IsElemental
Checks whether the item belongs to the Pentagram system (Pentagram or Errtel).
Item.IsElemental(itemCode) -> boolean
Returns: true if it is a Pentagram or Errtel. Short name: IsElementalItem (returns 1 / 0).
if Item.IsElemental(code) then ... end
Item.IsPentagram
Checks whether the item is a Pentagram according to the server's Pentagram system.
Item.IsPentagram(itemCode) -> boolean
Returns: true if it is a Pentagram. Short name: IsPentagramItem (returns 1 / 0).
if Item.IsPentagram(code) then ... end
Item.IsMasterPentagram
Checks whether the item is a Master-type Pentagram (with the mastery attribute).
Item.IsMasterPentagram(itemCode) -> boolean
Returns: true if it is a Master Pentagram.
local master = Item.IsMasterPentagram(code)
Item.IsPentagramJewel
Checks whether the item is a Pentagram Errtel jewel.
Item.IsPentagramJewel(itemCode) -> boolean
Returns: true if it is an Errtel.
local jewel = Item.IsPentagramJewel(code)
Item.IsMasterPentagramJewel
Checks whether the item is a Master-type Errtel jewel.
Item.IsMasterPentagramJewel(itemCode) -> boolean
Returns: true if it is a Master Errtel.
local master = Item.IsMasterPentagramJewel(code)
Item.GetMaxStack
Returns the maximum stack quantity of the item.
Item.GetMaxStack(itemCode) -> integer
Returns: the maximum quantity per slot; 0 if the item does not stack or the code does not exist.
if Item.GetMaxStack(code) > 0 then Log.Add("Can be stacked") end
Item.RandomAncientOption
Randomly picks a valid Ancient set option for the item, used for the Ancient field when creating an item.
Item.RandomAncientOption(itemCode) -> integer
Returns: the Ancient option value; 0 if the item does not belong to any set or the code does not exist. Short name: GetAncientOpt.
local anc = Item.RandomAncientOption(code)
Item.Give(aIndex, { Index = code, Ancient = anc })