Skip to content

Commit

Permalink
Simplify item set check (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
raethkcj committed Feb 3, 2022
1 parent e35e629 commit 3306a3c
Showing 1 changed file with 7 additions and 26 deletions.
33 changes: 7 additions & 26 deletions libs/StatLogic-1.0/StatLogic-1.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,40 +123,21 @@ end
--------------------
-- Item Set Cache --
--------------------
-- Maps ItemID to SetID
local item_set_cache = {}

-- Maps SetID to number of equipped pieces
local equipped_sets = setmetatable({}, {
__index = function(t, set)
local equipped = 0

for i = 1, INVSLOT_LAST_EQUIPPED do
local itemID = GetInventoryItemID("player", i)
if item_set_cache[itemID] == set then
t[set] = (rawget(t, set) or 0) + 1
else
local name = GetItemSetInfo(set)
if name then
local itemLink = GetInventoryItemLink("player", i)
tip:ClearLines()
if itemLink then tip:SetHyperlink(itemLink) end
for j = 1, tip:NumLines() do
local text = StatLogicTooltip[j]:GetText()
if text:find(name) then
item_set_cache[itemID] = set
t[set] = (rawget(t, set) or 0) + 1
break
end
end
else
t[set] = 0
end
if itemID and select(16, GetItemInfo(itemID)) == set then
equipped = equipped + 1
end
end
if not rawget(t, set) then
-- Set to zero so we don't scan again until next UNIT_INVENTORY_CHANGED
t[set] = 0
end
return rawget(t, set)

t[set] = equipped
return equipped
end
})

Expand Down

0 comments on commit 3306a3c

Please sign in to comment.