Thread Tools Display Modes
11-06-14, 06:26 AM   #1
Mirrikh
A Flamescale Wyrmkin
 
Mirrikh's Avatar
AddOn Compiler - Click to view compilations
Join Date: Sep 2011
Posts: 111
bXP Error

I seem to be getting this error from the xp addon I'm using
Code:
 bXP\bXP-1.0.lua:98: attempt to call global 'formatNumber' (a nil value)
bXP\bXP-1.0.lua:98: in function <bXP\bXP.lua:65>
not sure how to fix
Here's the relevant code
Code:
bar:SetScript("OnEvent", function()
    xp = UnitXP("player")
    mxp = UnitXPMax("player")
    rxp = GetXPExhaustion("player")
    name, standing, minrep, maxrep, value = GetWatchedFactionInfo()
    
    xpbar:SetMinMaxValues(0,mxp)
    if UnitLevel("player") == MAX_PLAYER_LEVEL or IsXPUserDisabled == true then
        if name then
            xpbar:SetStatusBarColor(FACTION_BAR_COLORS[standing].r, FACTION_BAR_COLORS[standing].g, FACTION_BAR_COLORS[standing].b, 1)
			xpbar:SetMinMaxValues(minrep,maxrep)
			xpbar:SetValue(value)
			xpbar.text:SetText(value-minrep.." / "..maxrep-minrep.." | "..floor(((value-minrep)/(maxrep-minrep))*1000)/10 .."% | ".. name)
            bar:Show()
        else
			bar:Hide()
        end
    else
        xpbar:SetStatusBarColor(unpack(config.color))
		xpbar:SetValue(xp)
		if rxp then
			xpbar.text:SetText(format(xp).." / "..format(mxp).." | "..floor((xp/mxp)*1000)/10 .."%" .. " (+"..format(rxp)..")")
			xpbar:SetMinMaxValues(0,mxp)
			xpbar:SetStatusBarColor(unpack(config.restedcolor))
			xpbar:SetValue(xp)
			if (rxp+xp) >= mxp then
				rxpbar:SetValue(mxp)
			else
				rxpbar:SetValue(rxp+xp)
			end
			rxpbar:Show()
			bar:Show()
		elseif xp then
			xpbar.text:SetText(formatNumber(xp).." / "..formatNumber(mxp).." | "..floor((xp/mxp)*1000)/10 .."%")
			rxpbar:Hide()
		end
    end
end)
  Reply With Quote
11-06-14, 06:43 AM   #2
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
The code is trying to call the function formatNumber, which doesn't exist in the scope of that statement. Is this function defined anywhere in the AddOn?
  Reply With Quote
11-06-14, 06:50 AM   #3
Mirrikh
A Flamescale Wyrmkin
 
Mirrikh's Avatar
AddOn Compiler - Click to view compilations
Join Date: Sep 2011
Posts: 111
only in that bit of code is it used.
  Reply With Quote
11-06-14, 07:04 AM   #4
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
The part of the function that handles rested XP appears to be using the format function to format its numbers, so you should probably use that for the non-rested part as well.

Is the format function defined by the AddOn or is it using the global alias of string.format? The latter would be pointless.
  Reply With Quote
11-06-14, 07:07 AM   #5
Mirrikh
A Flamescale Wyrmkin
 
Mirrikh's Avatar
AddOn Compiler - Click to view compilations
Join Date: Sep 2011
Posts: 111
I'm not too sure (not too good with lua), but I don't think it's defined by either.

Here's all the code.
  Reply With Quote
11-06-14, 07:23 AM   #6
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
That code doesn't seem to be very well written, it's leaking quite a few globals.

You'll want to replace the calls to format and formatNumber with BreakUpLargeNumbers.

You'll also want to replace IsXPUserDisabled == true with IsXPUserDisabled() (it's a function, not a boolean).

I'm not sure why the code is using format with a single numeric argument unless it used to be something other than an alias of string.format (which I don't think is the case).

Last edited by Choonstertwo : 11-06-14 at 07:25 AM.
  Reply With Quote
11-06-14, 07:39 AM   #7
Mirrikh
A Flamescale Wyrmkin
 
Mirrikh's Avatar
AddOn Compiler - Click to view compilations
Join Date: Sep 2011
Posts: 111
Thank you, that seems to have fixed it. Yea, it's kind of an old (not updated) addon, but it does what I like.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » bXP Error

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off