Compare & find an itemID in multiple lists

Hi all

I am in the middle of building an item filter that removes an item from a list.
With much help from Fizzlemizz I am much further along but once again I have a couple of questions.

Q1
I have a function to find matched items on my filtered and main lists, but my function is returning false when it is actually true.

local function isItemOnList(currentItem)
    for k, v in pairs(AAAGlobalItemLinkList) do
        if v == currentItem then
            print('item found')
            -- table.remove(AAAGlobalItemLinkList, k)
            return true
        else
            print('item not found')
            return false
        end
    end
end

Why is this happening? I cant understand how I messed this up.

Q2
I continue to have an issue where I have to spam the update function to display the item list in full when I login and/or reload.

local function updateScrollFrame()
    wipe(listItems)
    for index = 1, #AAAGlobalItemLinkList do
        if testItemRarity(AAAGlobalItemLinkList[index]) then
            tinsert(listItems, AAAGlobalItemLinkList[index])
        end
    end
    FauxScrollFrame_Update(testingScrollFrame, #listItems, NumberOfButtons, HeightOfButtons)
    for index = 1, NumberOfButtons do
        local offset = index + FauxScrollFrame_GetOffset(testingScrollFrame)
        local button = testingScrollFrame.buttons[index]
        if index > #listItems then
            button:SetText('')
            button.index = nil
        else
            button.index = offset
            local itemName, itemLink, _, _, _, _, _, _, _, _, _ = GetItemInfo(listItems[offset])
            button:SetText(itemLink)
        end
    end
end

I have this function fire when I login and reload but it still does not display the full list of buttons until I spam the update button.

Here are links to my code on pastebin;
Lua - /Sx6U2nYz
Toc - /DYj9BJ4J
(i still cant post links)

Any help that can explain how I have messed this up would be greatly received.

If you’re storing item links in the table then my guess is you’re comparing item name (Battle-Scarred Augment Rune) to the link which will look something like:
(|cff0070dd|Hitem:160053::::::::120:261::::::|h[Battle-Scarred Augment Rune]|h|r).

Along with registering PLAYER_LOGIN, register GET_ITEM_INFO_RECEIVED

1 Like

Hi Fizzlemizz
Thanks for your reply.

GET_ITEM_INFO_RECEIVED works perfectly, cheers. :slightly_smiling_face:

For the comparisons both of my lists store the itemID only so I am comparing a number to a number.
Would it be better to store the item link instead of the itemID so I can compare a string to a string?
If I store link will it still translate correctly in other languages?

I was guessing, I haven’t had a look at the code yet…

Looked:
add print(v, currentItem) right before if v == currentItem then in the isItemOnList function and see what you are comparing. That and your return on both conditions means you only ever check 1 item in the list.

1 Like

Hi Fizzlemizz

Thanks for the print test, (i should have thought of it myself), and it led to the issues I was having.
The value I was sending to the compare function was the index of the item temp list instead of the actual itemlink.

Once again thank for your help.