hey,
been working on making a Datatext view for Artifact power.
Im currently stuck on it always giving a error on first time login.
Getting this:
Code:
Message: Interface\FrameXML\MainMenuBar.lua:126: Usage: GetCostForPointAtRank(rank)
Time: 11/10/16 13:34:11
Count: 1
Stack: [C]: in function `GetCostForPointAtRank'
Interface\FrameXML\MainMenuBar.lua:126: in function <Interface\FrameXML\MainMenuBar.lua:124>
Interface\AddOns\ViksUI\Datatext\Artifact.lua:24: in function <Interface\AddOns\ViksUI\Datatext\Artifact.lua:22>
Locals: (*temporary) = nil
Here is my lua:
Lua Code:
local T, C, L, _ = unpack(select(2, ...))
--------------------------------------------------------------------
-- player Artifact
--------------------------------------------------------------------
if C.datatext.Artifact and C.datatext.Artifact > 0 then
local _G = _G
local format = format
local HasArtifactEquipped = HasArtifactEquipped
local MainMenuBar_GetNumArtifactTraitsPurchasableFromXP = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP
local C_ArtifactUI_GetEquippedArtifactInfo = C_ArtifactUI.GetEquippedArtifactInfo
local ARTIFACT_POWER = ARTIFACT_POWER
local Stat = CreateFrame("Frame")
Stat:EnableMouse(true)
Stat:SetFrameStrata("BACKGROUND")
Stat:SetFrameLevel(3)
local Text = LBottom:CreateFontString(nil, "OVERLAY")
local function Update(self)
local itemID, altItemID, name, icon, totalXP, pointsSpent = C_ArtifactUI_GetEquippedArtifactInfo()
local numPoints, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(pointsSpent, totalXP)
if C.datatext.Artifact >= 6 then
Text:SetTextColor(unpack(C.media.pxcolor1))
Text:SetFont(C.media.pxfontHeader, C.media.pxfontHsize, C.media.pxfontHFlag)
else
Text:SetTextColor(unpack(C.media.pxcolor1))
Text:SetFont(C.media.pixel_font, C.media.pixel_font_size, C.media.pixel_font_style)
end
PP(C.datatext.Artifact, Text)
local showArtifact = HasArtifactEquipped();
if not showArtifact then
Text:SetText("Artifact Not Equipped")
else
if C.datatext.Artifact >= 6 then
Text:SetText("|cffFFFFFF"..T.ShortValue(artifactXP).."/"..T.ShortValue(xpForNextPoint))
else
Text:SetText(qColor..T.ShortValue(artifactXP).."/"..T.ShortValue(xpForNextPoint))
end
self:SetAllPoints(Text)
end
end
Stat:RegisterEvent("ARTIFACT_XP_UPDATE")
Stat:RegisterEvent("UNIT_INVENTORY_CHANGED")
Stat:RegisterEvent("PLAYER_LOG_IN")
Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
Stat:SetScript("OnMouseDown", function() if not ArtifactFrame or not ArtifactFrame:IsShown() then ShowUIPanel(SocketInventoryItem(16)) elseif ArtifactFrame and ArtifactFrame:IsShown() then HideUIPanel(ArtifactFrame) end end)
Stat:SetScript("OnEvent", Update)
Stat:SetScript("OnEnter", function(self)
if not InCombatLockdown() then
GameTooltip:SetOwner(self, "ANCHOR_TOP", 0, 6);
GameTooltip:ClearAllPoints()
GameTooltip:SetPoint("BOTTOM", self, "TOP", 0, 1)
GameTooltip:ClearLines()
GameTooltip:AddLine(ARTIFACT_POWER)
local itemID, altItemID, name, icon, totalXP, pointsSpent = C_ArtifactUI_GetEquippedArtifactInfo();
local numPoints, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(pointsSpent, totalXP);
GameTooltip:AddDoubleLine(qColor.."Equiped: "..name..", Level: "..pointsSpent)
GameTooltip:AddDoubleLine("XP:", format(' %d / %d (%d%%)', artifactXP, xpForNextPoint, artifactXP/xpForNextPoint * 100), 1, 1, 1)
GameTooltip:AddDoubleLine("Remaining:", T.ShortValue(xpForNextPoint-artifactXP), 1, 1, 1)
GameTooltip:Show()
end
end)
Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
end
Everything seems to look as it should even with the error. It's just annoying, and i need to exit wow to get the error up again. As it doesn't show with simple reload ui or logout/login.
Any sugestions?