View Single Post
04-25-17, 06:44 AM   #7
jeruku
A Cobalt Mageweaver
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 223
Quick and dirty example.

Lua Code:
  1. local frame = CreateFrame('Frame')
  2. local tab = {}
  3. local wait = {}
  4.  
  5. frame:SetScript('OnEvent', function(self, event, ...)
  6.    if event == 'BAG_UPDATE_DELAYED' then
  7.       -- do checks and stuff and get the desired itemID
  8.       local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemID)
  9.       if not name then
  10.         wait[itemID] = {}
  11.      else
  12.         -- this may just create a library so you may have to put them in individually with something like tinsert(tab[itemID], name)...
  13.         tab[itemID] = {name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice}
  14.      end
  15.    elseif event == 'GET_ITEM_INFO_RECIEVED' then
  16.       -- the info is now downloaded and cached
  17.       local itemID = ...
  18.       if wait[itemID] then
  19.          tab[itemID] = {GetItemInfo(itemID)}
  20.          wait[itemID] = nil
  21.       end
  22.    end
  23. end
  24.  
  25. frame:RegisterEvent('BAG_UPDATE_DELAYED')
  26. frame:RegisterEvent('GET_ITEM_INFO_RECIEVED')
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison

Last edited by jeruku : 04-25-17 at 06:53 AM.
  Reply With Quote