helpers: add function to get item count

This commit is contained in:
shagu
2025-04-30 18:38:54 +02:00
parent d636d3d92f
commit c2cb97bf24
+21 -1
View File
@@ -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