Quantcast
WoWInterface - View Single Post - Convert ItemID's to Item Details
View Single Post
07-12-19, 07:33 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,929
I can't really think of any practical reason why caching this information is necessary. I would honestly loop through the list and run GetItemInfo() on load (ignoring the returns) to force the game to query the items, then run GetItemInfo() again on what specific item I need info on when I need it. Saves a lot of trouble in the long run with negligible if any resource impact.

If your list is really long, you may opt to build a queue.
Lua Code:
  1. local ItemQueue={};
  2. local function AddToQueue(itemid)
  3.     if #ItemQueue<=0 or not GetItemInfo(itemid) then--  Auto-queries server if this is the first entry, otherwise just adds to queue
  4.         table.insert(ItemQueue,itemid);--   Pushes to end of queue
  5.     end
  6. end
  7.  
  8. local QueueFrame=CreateFrame("Frame");
  9. QueueFrame:RegisterEvent("GET_ITEM_INFO_RECEIVED");
  10. QueueFrame:SetScript("OnEvent",function(_,_,itemid)
  11.     if ItemQueue[1]==itemid then--  Server responded to query
  12.         table.remove(ItemQueue,1);--    Shift queue
  13.         while #ItemQueue>0 do-- Loop until empty
  14.             if GetItemInfo(ItemQueue[1]) then-- Check if we have data
  15.                 table.remove(ItemQueue,1);--    Shift queue
  16.             else--  Query was sent
  17.                 break;--    Exit loop
  18.             end
  19.         end
  20.     end
  21. end);

PS: If GetItemInfoInstant() gets you all the info you need, I'd suggest using that instead as all the data that accesses is on the client, so it doesn't need to query the server.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 07-12-19 at 07:57 PM.
  Reply With Quote