Lua Code:
local backpackSlots = GetBagSize and GetBagSize(bag) or select(2, GetBagInfo(bag))
Is no longer needed. It was compatibility function to make addon work with both API 100007 and 100008 (because of PTS). Just use:
Lua Code:
local backpackSlots = GetBagSize(bag)
Lua Code:
for i=1, backpackSlots do
Inventory slots are the only index value in ESO which starts with zero. So the correct code is:
Lua Code:
for i = 0, backpackSlots - 1 do
Lua Code:
backpackItem = GetItemLink(BAG_BACKPACK, i, LINK_ITEM_TYPE)
I have no idea how you have defined LINK_ITEM_TYPE, but you should use LINK_STYLE_DEFAULT or LINK_STYLE_BRACKETS.
Lua Code:
backpackItem = GetItemLink(BAG_BACKPACK, i, LINK_STYLE_BRACKETS)
Lua Code:
if string.match(backpackItem, COLLECTIBLE_ITEM_TYPE_TROPHY) then
Global constant COLLECTIBLE_ITEM_TYPE_TROPHY is not what you are looking for. Value of COLLECTIBLE_ITEM_TYPE_TROPHY is number 2, so your function returns all itemlinks which contains number 2.
You should use item type instead, something like:
Lua Code:
if GetItemLinkItemType(backpackItem) == ITEMTYPE_TROPHY then --if you want collectibles, use ITEMTYPE_COLLECTIBLE
Anyway, try this code:
Lua Code:
local bagCache = SHARED_INVENTORY:GenerateFullSlotData(nil, BAG_BACKPACK)
for slotIndex, slotData in pairs(bagCache) do
if slotData.itemType == ITEMTYPE_TROPHY then
d(zo_strformat("<<1>> (<<2>>)", slotData.name, slotIndex))
end
end