Files
wow-weakauras/WeakAuras/Projects/TSU - Item Monitor.lua

38 lines
1.2 KiB
Lua

--REMOVE_ITEM_SHOW ADD_ITEM_SHOW
function(allstates, e, what, howmuch)
if e == "ADD_ITEM_SHOW" then
if what then
--Get info about item
local icon = 0
local name = GetItemInfo(what)
--Save icon to databases
if not WeakAurasSaved.CustomTrash.IconDatabase[name] then icon = select(10, GetItemInfo(name)) else icon = WeakAurasSaved.CustomTrash.IconDatabase[name] end
if name and icon and not WeakAurasSaved.CustomTrash.IconDatabase[name] then WeakAurasSaved.CustomTrash.IconDatabase[name] = icon; print("Adding|cff78cb00 ", name, " |rto the icon database") end
--Get ID for tooltip
local indexid = #allstates + 1
local ID
if WeakAurasSaved.CustomTrash.IDDatabase[name] then ID = WeakAurasSaved.CustomTrash.IDDatabase[name] end
allstates[indexid] =
{
show = true,
changed = true,
index = GetTime(),
resort = true,
icon = icon,
name = what,
amount = howmuch,
}
if ID then
allstates[indexid].itemId = ID
end
C_Timer.After(5, function() WeakAuras.ScanEvents("REMOVE_ITEM_SHOW", indexid) end)
return true
end
elseif e == "REMOVE_ITEM_SHOW" then
if allstates[what] then
allstates[what].show = false
allstates[what].changed = true
return true
end
end
end