LUACN论坛

 找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
热搜: YJWOW MagicStone BoL
查看: 178|回复: 9

[wowbee] Bee关于物品使用次数的判定函数

[复制链接]
发表于 2023-6-29 13:53:53 | 显示全部楼层 |阅读模式
在编写FS脚本时想新增一个项功能,就是在脱战之后判定“法力青玉”是否为3次使用,如果不是3次,就自动使用“制造法力宝石”;
但目前所知道的函数GetItemCount和IsEquippableItem都只能判定是否有“法力青玉”,不能判定次数是否是3次;
请问各位大佬是否知道判定物品使用次数的函数;
回复

使用道具 举报

发表于 2023-6-29 14:15:48 | 显示全部楼层
GetItemCount(ID或物品名字)
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-6-29 14:31:37 | 显示全部楼层
lk47354813 发表于 2023-6-29 02:15 PM
GetItemCount(ID或物品名字)

“法力青玉”能用3次,我想实现一次战斗之后次数少于3次(2次 or 1次)也能自动重新做一个,用GetItemCount无法实现
回复 支持 反对

使用道具 举报

发表于 2023-6-29 15:46:20 | 显示全部楼层
用宏把不足3次的摧毁再做不就行了吗
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-6-29 17:43:52 | 显示全部楼层
lk47354813 发表于 2023-6-29 03:46 PM
用宏把不足3次的摧毁再做不就行了吗

现在就是没办法判定使用次数是否为3次,如果不论使用次数,又会陷入摧毁、制造、摧毁的循环里
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-7-4 14:46:16 | 显示全部楼层
没有哪位大神帮忙一下嘛,FS脚本就快完成了
回复 支持 反对

使用道具 举报

发表于 2023-7-7 09:32:00 | 显示全部楼层
itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType,
itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID, bindType,
expacID, setID, isCraftingReagent
    = GetItemInfo(item)

itemStackCount:堆栈计数,行不行?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-7-7 10:20:01 | 显示全部楼层
hushuai 发表于 2023-7-7 09:32 AM
itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType,
itemStackCount, it ...

谢谢大神,一会测试一下,希望有用
回复 支持 反对

使用道具 举报

发表于 2023-7-11 11:01:27 | 显示全部楼层
本帖最后由 懒动行不行 于 2023-7-11 11:16 AM 编辑

使用这个函数
GetItemCount

[Lua] 纯文本查看 复制代码
count = GetItemCount(itemInfo [, includeBank, includeUses, includeReagentBank])


返回库存物品的数量(或者可用的使用次数)。

参数
itemInfo
数字或字符串型- 物品的ID, 链接 或名称
includeBank
布尔型? -是否为真, 包括存放在银行中
includeUses
布尔型? - 是否为真, 包括物品的每次使用,类似于 GetActionCount([size=90%])
includeReagentBank
布尔型? - 是否为真, 包括试剂银行
返回值

count数字型 - 您拥有的物品数量,或使用次数(includeUses为真且有使用次数)。
示例
[Lua] 纯文本查看 复制代码
local count = GetItemCount(29434)
print("Badge of Justice:", count)

local count = GetItemCount(33312, nil, true) 
print("Mana Saphire Charges:", count)

local clothInBags = GetItemCount("Netherweave Cloth")
local clothInTotal = GetItemCount("Netherweave Cloth", true)
print("Netherweave Cloth:", clothInBags, "(bags)", (clothInTotal - clothInBags), "(bank)")

补丁更新

[/url][url=https://wowpedia.fandom.com/wiki/Patch_7.2.0/API_changes]Patch 7.2.0 (2017-03-28): Added includeReagentBank optional argument.[1]   
[/url][url=https://wowpedia.fandom.com/wiki/Patch_2.3.0/API_changes]Patch 2.3.0 (2007-11-13): Added includeUses optional argument.[2]   
参考文献



因此针对楼主的需求,下面是一个示例,可以根据实际情况增加判断条件,以更好的满足实际需求


[Lua] 纯文本查看 复制代码
function DelPoor(itemID)
      for bag = 0,4,1 do 

         for slot = 1, GetContainerNumSlots(bag), 1 do
              local name = GetContainerItemLink(bag,slot)
              local desname = (select(2,GetItemInfo(itemID)))
             if name == desname then
                    PickupContainerItem(bag,slot)
                    DeleteCursorItem(bag,slot)
              end 

        end
     end
 end

local n=GetItemCount("法力青玉",nil,true)
if not BeeUnitAffectingCombat("player") and n<3 then DelPoor("法力青玉");BeeRun("制造法力青玉") end


这里面用到了玄月无尘大佬的摧毁物品函数,法力青玉和制造法力青玉名称我没有确认过,需要你根据实际的名称修改,有问题可以再反馈讨论。
















本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?加入我们

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-7-11 17:48:29 | 显示全部楼层
懒动行不行 发表于 2023-7-11 11:01 AM
使用这个函数
GetItemCount

大神,请收下小弟的膝盖
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

小黑屋|手机版|Archiver|LUACN论坛

GMT+8, 2024-5-11 06:50 PM , Processed in 0.061918 second(s), 31 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表