Originally Posted by liquidbase
local XP, maxXP, restXP = UnitXP("player"), UnitXPMax("player"), GetXPExhaustion()
local percXP = ((XP == 0) and (maxXP == 0)) or (math.floor((XP / maxXP) * 100))
|
That second line is the problem; I don't think it's doing what you think it's doing. What you wrote is the equivalent of this:
Code:
if XP == 0 and maxXP == 0 then
percXP = true
else
percXP = floor(XP / maxXP * 100)
end
SDPhantom's suggestion will prevent the error from showing up, but I'd suggest doing this instead:
Code:
local XP, maxXP, restXP = UnitXP("player"), UnitXPMax("player"), GetXPExhaustion()
if not maxXP or maxXP == 0 then return end
local percXP = floor(XP / maxXP * 100)
There's no point in going on with the rest of your display logic if you don't have any valid information to display, or you just end up displaying wrong information.