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:
local frame = CreateFrame("Frame")
local function ReportInstanceInfo(info)
if info then
print(info.itemID,info.name,info.link)
end
end
local function GetInstanceLoot(instanceID)
EJ_SelectInstance(instanceID)
local numLoot = EJ_GetNumLoot()
local itemInfo = {}
for i = 1, numLoot do
local itemInfo = C_EncounterJournal.GetLootInfoByIndex(i)
if itemInfo.name then
print("Loot Data Available Now: ")
ReportInstanceInfo(itemInfo)
else
print("Waiting for Loot Data: ")
end
end
end
local function SlashCommands(msg, editbox)
local emptyvar,emptyvar, cmd, args = string.find(msg, "%s?(%w+)%s?(.*)")
if cmd == "inst" then
GetInstanceLoot(args)
elseif cmd == "help" then
print("Syntax: /xls (help/inst ####)")
end
end
SLASH_XLS1, SLASH_XLS2 = '/xls', '/xui_lootsearcher'
SlashCmdList["XLS"] = SlashCommands
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("EJ_LOOT_DATA_RECIEVED")
frame:SetScript("OnEvent",function(self,event,...)
local args = { ... }
if event == "EJ_LOOT_DATA_RECIEVED" then
print("Loot Data Received: ",args[1])
local itemID = args[1]
if itemID then
local itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount,
itemEquipLoc, itemTexture, sellPrice, classID, subclassID, bindType, expacID, setID, isCraftingReagent
= GetItemInfo(itemID)
print(itemID,itemName,itemLink)
end
end
end)