helpers: add function to get item count
This commit is contained in:
+21
-1
@@ -171,7 +171,6 @@ ShaguTweaks.cmatch = function(str, pat)
|
||||
return ra, rb, rc, rd, re
|
||||
end
|
||||
|
||||
|
||||
local timer
|
||||
ShaguTweaks.QueueFunction = function(a1,a2,a3,a4,a5,a6,a7,a8,a9)
|
||||
if not timer then
|
||||
@@ -338,3 +337,24 @@ end
|
||||
ShaguTweaks.spairs = function(t)
|
||||
return orderedNext, t, nil
|
||||
end
|
||||
|
||||
ShaguTweaks.GetItemCount = function(itemName)
|
||||
local count = 0
|
||||
for bag = 4, 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 queryName = GetItemInfo(itemParse)
|
||||
if queryName and queryName ~= "" then
|
||||
if queryName == itemName then
|
||||
count = count + itemCount
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return count
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user