Fix equipped-item match in FindItemIcon and drop the link loop

The equipped-slot check compared itemName to its own lowercase (always matching the first named slot) instead of the searched item; now it compares against item. The separate GetInventoryItemLink/ItemLinkToName loop for slots past INVSLOT_LAST_EQUIPPED is folded into the ItemLocation loop by extending its range by 4.
This commit is contained in:
Brues
2026-06-22 19:09:27 -05:00
parent 6418359865
commit 8c35b8b6ad
@@ -1950,22 +1950,13 @@ end
function MikSBT.FindItemIcon(item)
if ( not item ) then return end
item = string.lower(item);
for slot = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
for slot = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED + 4 do
local itemLocation = ItemLocation:CreateFromEquipmentSlot(slot)
local itemName = C_Item.GetItemName(itemLocation)
if itemName and itemName == string.lower(itemName) then
if itemName and item == string.lower(itemName) then
return slot, nil, C_Item.GetItemIcon(itemLocation), GetInventoryItemCount('player', slot)
end
end
local link;
for i = INVSLOT_LAST_EQUIPPED + 1, 23 do
link = GetInventoryItemLink("player",i);
if ( link ) then
if ( item == string.lower(ItemLinkToName(link)) )then
return i, nil, GetInventoryItemTexture('player', i), GetInventoryItemCount('player', i);
end
end
end
local count, texture;
for i = 0, NUM_BAG_FRAMES do
for j = 1, GetContainerNumSlots(i) do