本页的函数从服务器的 ItemList 中读取物品类型数据,不需要角色。它们都接收 itemCode,即物品代码(分组 * 512 + 序号,范围 0 到 65535)。如果代码不存在,函数返回各函数中注明的默认值。
通用参数:
| 参数 | 类型 | 说明 |
|---|---|---|
itemCode | integer | 物品代码 |
Item.IsValid
检查物品代码是否存在于 ItemList 中。
Item.IsValid(itemCode) -> boolean
返回:存在时返回 true。简称:IsItem(返回 1 / 0)。
if not Item.IsValid(code) then Log.AddC(1, "物品代码错误 " .. code) end
Item.GetName
返回物品名称。
Item.GetName(itemCode) -> string
返回:物品名称;代码不存在时返回空字符串。
Message.Send(aIndex, 1, "您获得了 " .. Item.GetName(code))
Item.GetKindA
返回物品的类型分组 A(Kind1)。
Item.GetKindA(itemCode) -> integer
返回:分组 A 的代码;代码不存在时返回 0。简称:GetItemKindA。
该值取自服务器 ItemList.xml 中物品的 KindA 列,因此每个数字的含义由该文件中的分类表决定(请查阅该文件;脚本中没有固定的对照表)。GameServer 使用的示例:KindA 45 - 49 和 56 为 Legendary 物品。
local kind = Item.GetKindA(code)
Item.GetKindB
返回物品的类型分组 B(Kind2)。
Item.GetKindB(itemCode) -> integer
返回:分组 B 的代码;代码不存在时返回 0。
该值取自 ItemList.xml 中物品的 KindB 列(各数字的含义请查阅该文件)。GameServer 使用的示例:KindB 60 为 Conqueror 翅膀,76 为 4 级翅膀,106 为 5 级翅膀。
local kind = Item.GetKindB(code)
Item.GetSize
返回物品在背包中占用的尺寸(格数)。
Item.GetSize(itemCode) -> width, height
返回:2 个数字:宽度和高度;代码不存在时返回 0, 0。
local w, h = Item.GetSize(code)
if Inventory.HasSpace(aIndex, w, h) then ... end
Item.IsSocket
检查物品是否属于可以拥有孔位(socket)的类型。
Item.IsSocket(itemCode) -> boolean
返回:是 socket 物品时返回 true。简称:IsSocketItem(返回 1 / 0)。
if Item.IsSocket(code) then ... end
Item.IsExcSocketAccessory
检查物品是否为 socket 饰品(socket 类型的项链或戒指)。
Item.IsExcSocketAccessory(itemCode) -> boolean
返回:是 socket 项链 / 戒指时返回 true。
local acc = Item.IsExcSocketAccessory(code)
Item.IsElemental
检查物品是否属于 Pentagram 体系(Pentagram 或 Errtel)。
Item.IsElemental(itemCode) -> boolean
返回:是 Pentagram 或 Errtel 时返回 true。简称:IsElementalItem(返回 1 / 0)。
if Item.IsElemental(code) then ... end
Item.IsPentagram
按服务器的 Pentagram 系统检查物品是否为 Pentagram。
Item.IsPentagram(itemCode) -> boolean
返回:是 Pentagram 时返回 true。简称:IsPentagramItem(返回 1 / 0)。
if Item.IsPentagram(code) then ... end
Item.IsMasterPentagram
检查物品是否为 Master 类型的 Pentagram(带有 mastery 属性)。
Item.IsMasterPentagram(itemCode) -> boolean
返回:是 Master Pentagram 时返回 true。
local master = Item.IsMasterPentagram(code)
Item.IsPentagramJewel
检查物品是否为 Pentagram 的 Errtel 宝石。
Item.IsPentagramJewel(itemCode) -> boolean
返回:是 Errtel 时返回 true。
local jewel = Item.IsPentagramJewel(code)
Item.IsMasterPentagramJewel
检查物品是否为 Master 类型的 Errtel 宝石。
Item.IsMasterPentagramJewel(itemCode) -> boolean
返回:是 Master Errtel 时返回 true。
local master = Item.IsMasterPentagramJewel(code)
Item.GetMaxStack
返回物品的最大堆叠数量。
Item.GetMaxStack(itemCode) -> integer
返回:每格的最大数量;如果物品不可堆叠或代码不存在,则返回 0。
if Item.GetMaxStack(code) > 0 then Log.Add("可以堆叠") end
Item.RandomAncientOption
为物品随机选取一个有效的 Ancient 套装选项,用于创建物品时的 Ancient 字段。
Item.RandomAncientOption(itemCode) -> integer
返回:Ancient 选项的值;如果物品不属于任何套装或代码不存在,则返回 0。简称:GetAncientOpt。
local anc = Item.RandomAncientOption(code)
Item.Give(aIndex, { Index = code, Ancient = anc })