本帖最后由 懒动行不行 于 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)")
补丁更新
参考文献
因此针对楼主的需求,下面是一个示例,可以根据实际情况增加判断条件,以更好的满足实际需求
[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
这里面用到了玄月无尘大佬的摧毁物品函数,法力青玉和制造法力青玉名称我没有确认过,需要你根据实际的名称修改,有问题可以再反馈讨论。
|