clean GetItemCount

This commit is contained in:
Crum
2018-02-21 11:29:42 -06:00
parent 612c53d6d5
commit 7f58853bd5
+5 -5
View File
@@ -7,7 +7,7 @@ local select = select
local tonumber = tonumber
local type = type
local unpack = unpack
local format, gsub, lower, match, upper = string.format, string.gsub, string.lower, string.match, string.upper
local find, format, gsub, lower, match, upper = string.find, string.format, string.gsub, string.lower, string.match, string.upper
local getn = table.getn
--WoW API
local GetItemInfo = GetItemInfo
@@ -403,16 +403,16 @@ end
function GetItemCount(itemName)
local count = 0
for bag = 4, 0, -1 do
for bag = NUM_BAG_FRAMES, 0, -1 do
for slot = 1, GetContainerNumSlots(bag) do
local _, itemCount = GetContainerItemInfo(bag, slot)
if itemCount then
local itemLink = GetContainerItemLink(bag,slot)
local _, _, itemParse = strfind(itemLink, "(%d+):")
local itemLink = GetContainerItemLink(bag, slot)
local _, _, itemParse = find(itemLink, "(%d+):")
local queryName, _, _, _, _, _ = GetItemInfo(itemParse)
if queryName and queryName ~= "" then
if queryName == itemName then
count = count + itemCount
count = count + itemCount
end
end
end