View Single Post
04-15-21, 03:53 PM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
This is about the best I could do.

It seems that when you first request a look up it doesn't get it all even on callback. However, another request a short time later it will work. I tried to request it a second time on callback but it still doesn't work. But requesting it manually it does.

However, you could use the callback that returns the items ID to use the item functions GetItemInfo(itemID) to get the item details.

What the Encounter Journal does is look at the scroll list in the encounter journal for that itemID to get the index in the encounter for that item to get the original index. I tried to simulate this by storing the last index requested but it didn't work.

When it successfully finds the items and their details using the Encounter Loot function it returns a handful of items ranging from greens, blues, even oranges. However, when it didn't succeed and the event callback had to be used, the items returned at that point are the ones from the original list but also others that weren't in that initial list. This could be because of the waiting time that is in place so maybe some were ready immediately and others weren't. Saving to a savedvariables file to see if the same items do eventually appear with their details may be useful.

Anyway give this a play for testing purposes and change it to fit your requirements. At least until someone comes along with a better solution

Lua Code:
  1. local frame = CreateFrame("Frame")
  2.  
  3. local function ReportInstanceInfo(info)
  4.     if info then
  5.         print(info.itemID,info.name,info.link)
  6.     end
  7. end
  8.  
  9. local function GetInstanceLoot(instanceID)
  10.     EJ_SelectInstance(instanceID)
  11.     local numLoot = EJ_GetNumLoot()
  12.     local itemInfo = {}
  13.     for i = 1, numLoot do
  14.         local itemInfo = C_EncounterJournal.GetLootInfoByIndex(i)
  15.         if itemInfo.name then
  16.             print("Loot Data Available Now: ")
  17.             ReportInstanceInfo(itemInfo)
  18.         else
  19.             print("Waiting for Loot Data: ")
  20.         end
  21.     end
  22. end
  23.  
  24. local function SlashCommands(msg, editbox)
  25.     local emptyvar,emptyvar, cmd, args = string.find(msg, "%s?(%w+)%s?(.*)")
  26.     if cmd == "inst" then
  27.         GetInstanceLoot(args)
  28.     elseif cmd == "help" then
  29.         print("Syntax: /xls (help/inst ####)")
  30.     end
  31. end
  32. SLASH_XLS1, SLASH_XLS2 = '/xls', '/xui_lootsearcher'
  33. SlashCmdList["XLS"] = SlashCommands
  34.  
  35.  
  36. frame:RegisterEvent("ADDON_LOADED")
  37. frame:RegisterEvent("EJ_LOOT_DATA_RECIEVED")           
  38. frame:SetScript("OnEvent",function(self,event,...)
  39.     local args = { ... }
  40.     if event == "EJ_LOOT_DATA_RECIEVED" then
  41.         print("Loot Data Received: ",args[1])
  42.         local itemID = args[1]
  43.         if itemID then
  44.             local itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount,
  45. itemEquipLoc, itemTexture, sellPrice, classID, subclassID, bindType, expacID, setID, isCraftingReagent
  46.    = GetItemInfo(itemID)
  47.             print(itemID,itemName,itemLink)
  48.         end
  49.     end
  50. end)
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote