View Single Post
01-10-21, 05:40 AM   #1
Nattugglan
A Defias Bandit
Join Date: Sep 2010
Posts: 2
attempt to compare number with nil

Getting the "error attempt to compare number with nil" with my very simply weakaura that shows my rested experience.

Error:
12x [string "--[==[ Error in 'DataTexts-Rested%':'custom..."]:5: attempt to compare number with nil
[string "=[C]"]: in function `xpcall'
[string "@WeakAuras\WeakAuras-3.1.8.lua"]:4073: in function `RunCustomTextFunc'
[string "@WeakAuras\RegionTypes\Text.lua"]:219: in function `FrameTick'
[string "@WeakAuras\RegionTypes\RegionPrototype.lua"]:646: in function <...aceWeakAuras\RegionTypes\RegionPrototype.lua:638>

My code:
function()
local restedxp = GetXPExhaustion()
local totalXP = UnitXPMax("player")
if restedxp == 0 then return end
if restedxp > 0 then percent = floor((restedxp / totalXP) * 100) end

local ret = string.format("%d%%", percent)
return ret
end

Need help please! : )
  Reply With Quote