So I got tired of the way XP was displaying on my alt, and decided to code a tooltip to display it instead. But I can't get the tooltip to show and display the message, no Lua errors are displaying for assistance.
Where did I go wrong?
Code:
local a = CreateFrame("Frame", "CalXP")
a:RegisterEvent("CHAT_MSG_COMBAT_XP_GAIN")
a:RegisterEvent("PLAYER_LOGIN")
a:SetScript("OnEvent", function(self)
local level = UnitLevel("PLAYER")
local currXP = UnitXP("PLAYER")
local nxtLevel = level + 1
local playerMaxXP = UnitXPMax("PLAYER")
local oldXP = currXP
-- Should add a game tooltip to the main window
GameTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE")
GameTooltip:SetTitle("calXP View")
--[[ this didnt work
GameTooltip:SetWidth = 60
GameTooltip:SetHeight = 18
]]--
ShowUIPanel(GameTooltip)
--
if level == 85 then
GameTooltip:AddLine("You have reached Max Level\n"..
"This mod is of no use to this character.")
else
GameTooltip:AddLine("You are " ..playerMaxXP - oldXP.. " experience points away from level: " ..nxtLevel)
end
end