Quick and dirty example.
Lua Code:
local frame = CreateFrame('Frame')
local tab = {}
local wait = {}
frame:SetScript('OnEvent', function(self, event, ...)
if event == 'BAG_UPDATE_DELAYED' then
-- do checks and stuff and get the desired itemID
local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemID)
if not name then
wait[itemID] = {}
else
-- this may just create a library so you may have to put them in individually with something like tinsert(tab[itemID], name)...
tab[itemID] = {name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice}
end
elseif event == 'GET_ITEM_INFO_RECIEVED' then
-- the info is now downloaded and cached
local itemID = ...
if wait[itemID] then
tab[itemID] = {GetItemInfo(itemID)}
wait[itemID] = nil
end
end
end
frame:RegisterEvent('BAG_UPDATE_DELAYED')
frame:RegisterEvent('GET_ITEM_INFO_RECIEVED')