Skip to content

道具模块管理接口 Item

具体函数名及描述如下:

序号函数名函数描述
1GetItemName(...)获取道具名称
2RandomItemID(...)在资源库里随机获取一个道具ID
3RandomProjectileID(...)在资源库里随机获取一个投掷物ID
4GetItemDesc(...)获取道具类型描述
5GetAttr(...)获取道具属性
6GetCustomGunAttr(...)获取自定义道具的属性
7GetGunBaseDesc(...)获取枪械基本描述

GetItemName

  • 参数及类型:
    • itemid:number,string道具ID
  • 返回值及类型:
  • 该方法的主要作用: 获取道具名称
  • 具体使用案例如下:
lua
    local itemName = Item:GetItemName(12005)

    if itemName then

        print("获取物品名称", itemName)

    end

RandomItemID

  • 参数及类型: 无
  • 返回值及类型:
  • 该方法的主要作用: 在资源库里随机获取一个道具ID
  • 具体使用案例如下:
lua
    local itemID = Item:RandomItemID()

    if itemID then

        print("随机生成的物品ID", itemID)

    end

RandomProjectileID

  • 参数及类型: 无
  • 返回值及类型:
  • 该方法的主要作用: 在资源库里随机获取一个投掷物ID
  • 具体使用案例如下:
lua
    local projectileID = Item:RandomProjectileID()

    if projectileID then

        print("随机生成的投射物ID", projectileID)

    end

GetItemDesc

  • 参数及类型:
    • itemid:number,string道具ID
  • 返回值及类型:
  • 该方法的主要作用: 获取道具类型描述
  • 具体使用案例如下:
lua
    local itemDesc = Item:GetItemDesc(12005)

    if itemDesc then

        print("获取物品描述", itemDesc)

    end

GetAttr

  • 参数及类型:
    • itemid:number,string道具ID
    • attr:number属性类型枚举(ItemAttr)ItemAttr
  • 返回值及类型:
  • 该方法的主要作用: 获取道具属性
  • 具体使用案例如下:
lua
    local attr = Item:GetAttr(12005, ItemAttr.Attack)

    if attr then

        print("获取攻击力", attr)

    end

GetCustomGunAttr

  • 参数及类型:
    • itemid:number,string道具ID
    • attrname:string属性名
  • 返回值及类型:
    • val:any返回的值
  • 该方法的主要作用: 获取自定义道具的属性
  • 具体使用案例如下:
lua
local val = Item:GetCustomGunAttr(itemid, attrname)

GetGunBaseDesc

  • 参数及类型:
    • itemid:number/string道具ID
  • 返回值及类型:
  • 该方法的主要作用: 获取枪械基本描述
  • 具体使用案例如下:
lua
local ret = Item:GetGunBaseDesc(itemid)