This is not about auctions, value of items or gold. Just for my own personal use of keeping track of what items I looted.
I know how to get the item details using GetItemInfo but I don't know how to get the "just looted" item's details, and then save that info to a saved variables file.
Code:
LootLog = {}
local f = CreateFrame("Frame")
local function Log_Loot(tooltip)
-- 1. Get looted item id, name, item level, type, subtype
local item = tooltip:GetItem()
local itemName = GetItemInfo(item)
local _, itemLink = GetItemInfo(item) -- I need to extract item ID from this somehow.
local _, _, _, itemLevel = GetItemInfo(item)
local _, _, _, _, _, itemType = GetItemInfo(item)
local _, _, _, _, _, _, itemSubType = GetItemInfo(item)
-- 2. Save the above info to saved variables file.
table.insert(LootLog, itemName.."/"..itemLink.."/"..itemLevel.."/"..itemType.."/"..itemSubType.."\n")
end
f:SetScript("OnEvent", Log_Loot)
f:RegisterEvent("ITEM_PUSH")
Need a little help here, thank you.
- - - Updated - - -
SOLVED! Inspecting some addons which display looted item info, I was finally able to get the info about the looted item, and then store it in the saved variables file using the following:
Code:
LootLog = {}
local f = CreateFrame("Frame")
f:RegisterEvent("LOOT_OPENED")
local function Log_Loot()
local n = GetNumLootItems()
for i = 1, n do
local item = GetLootSlotLink(i)
local itemName = select(1, GetItemInfo(item))
local itemLink = select(2, GetItemInfo(item))
local itemId = select(2, strsplit(":", itemLink, 3))
local itemRarity = select(3, GetItemInfo(item))
local itemLevel = select(4, GetItemInfo(item))
local itemReqLevel = select(5, GetItemInfo(item))
local itemType = select(6, GetItemInfo(item))
local itemSubType = select(7, GetItemInfo(item))
local itemPrice = select(11, GetItemInfo(item))
local text = itemName.."/"..itemId.."/"..itemRarity.."/"..itemLevel.."/"..itemReqLevel.."/"..itemType.."/"..itemSubType.."/"..itemPrice
table.insert(LootLog, text)
end
end
f:SetScript("OnEvent", Log_Loot)
This seems to work only for looted items (e.g. it doesn't work for items you receive via crafting, trading, mail, quests etc.). Not ideal but I guess I can live with it. Just keeping this here in case anyone might need a similar functionality in the future.