View Single Post
04-09-15, 07:29 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
And if you're looking for something a bit simpler that just prints messages to chat when your ilvl changes, instead of showing it in an always-visible frame, you can try this (totally untested):

Code:
local ilvl = -1

local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:RegisterEvent("PLAYER_AVG_ITEM_LEVEL_UPDATE")
f:SetScript("OnEvent", function()
	local total, equipped = GetAverageItemLevel()
	total = math.floor(total)
	if total == ilvl then
		return
	end
	local color = ChatTypeInfo["SYSTEM"]
	if total > ilvl then
		DEFAULT_CHAT_FRAME:AddMessage("Your average item level is now |cff99ff99" .. total .. "|r, up from " .. ilvl, color.r, color.g, color.b)
	else
		DEFAULT_CHAT_FRAME:AddMessage("Your average item level is now |cffff9999" .. total .. "|r, down from " .. ilvl, color.r, color.g, color.b)
	end
	ilvl = total
end)
If you need help turning the above code into an addon, copy and paste it into this page:
http://addon.bool.no/
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote