View Single Post
06-13-17, 01:25 AM   #1
loff93
A Fallenroot Satyr
Join Date: Apr 2017
Posts: 25
How to get item texture path

Hey,

Finally done with exams and wanna progress on my addon. I'm quite new to lua but I'm starting to see how it works.

I got a function tha grabs item info, so I get the item name. My issue is that I can't get access to the itemTexture and it doesn't seem like GetItemInfo is actually returning anything but ID/Name of the item? Might be me using it wrong or so.. Could anyone explain how I can for example access Item Path or vendorPrice ?

Code:
  
    local wait = {}
    local cache_writer = CreateFrame('Frame')
    cache_writer:RegisterEvent('GET_ITEM_INFO_RECEIVED')
    cache_writer:SetScript('OnEvent', function(self, event, ...)
        if event == 'GET_ITEM_INFO_RECEIVED' then
            -- the info is now downloaded and cached
            local itemID = ...
            if wait[itemID] then
                --print("received",itemID)
				testing2(itemID)
                wait[itemID] = nil
            end
        end
    end)
     
    local function normal_loop()
        --using for instead of ipairs because want to preserve order
        for index = 1, numMaterials, 1 do
            local itemID = craftingMaterials[index]
            local name = GetItemInfo(itemID)
			--local stringtest = GetItemInfo(itemID.itemTexture)
            if name then
				print(name.itemTexture)
                testing2(name)
            else
                --add item to wait list
                wait[itemID] = {}
            end
        end
    end
     
    local initframe = CreateFrame("Frame", "MyInitFrame", UIParent)
    initframe:RegisterEvent("PLAYER_LOGIN")
    initframe:SetScript("OnEvent", function(self, event, ...)
        if event == "PLAYER_LOGIN" then
            normal_loop()
        end
    end)
I guess I have to do something like
name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemID) or GetItemInfo("itemName") or GetItemInfo("itemLink")

To actually store what I need.

Last edited by loff93 : 06-13-17 at 01:31 AM.
  Reply With Quote