Character Stats not loading on PLAYER_LOGIN
Hello, I am new and noob to WoW addons development.
As an exercise I am trying to do a little panel with player stats in it, but actually I am failing to do so :D
With the following code, when I enter into the game my stat is 0.000.
Any help? Thanks in advance! ;)
Lua Code:
function round(number, decimals) return (("%%.%df"):format(decimals)):format(number) end local crit = round(GetCritChance(), 3) local c = CreateFrame("Frame", "myframe", UIParent) c:SetWidth(400) c:SetHeight(200) c:SetPoint("TOP", UIParent, "CENTER") c:SetFrameStrata("MEDIUM") c.tex = c:CreateTexture() c.tex:SetAllPoints(c) c.tex:SetColorTexture( unpack(cfg.color)) c.text = c:CreateFontString(nil,"ARTWORK","GameFontNormal") c.text:SetPoint("TOPLEFT",8,-10) c.text:SetTextColor(classColor.r, classColor.g, classColor.b) c:RegisterEvent("PLAYER_LOGIN") c:SetScript("OnEvent", function() c.text:SetText( "Crit: " .. crit ) end)
|