Thread Tools Display Modes
09-25-15, 01:11 PM   #1
kawe
A Cyclonian
 
kawe's Avatar
Join Date: Sep 2009
Posts: 40
bad argument

Code:
Message: Interface\AddOns\oUF_Mu\core\layout.lua:242: bad argument #2 to 
'SetFormattedText' (string expected, got boolean)
Time: 09/25/15 21:04:13
Count: 1
Stack: [C]: in function `SetFormattedText'
Interface\AddOns\oUF_Mu\core\layout.lua:242: in function
 <Interface\AddOns\oUF_Mu\core\layout.lua:241>
(tail call): ?
(tail call): ?
(tail call): ?
Interface\AddOns\oUF\elements\altpowerbar.lua:143: in function `func'
Interface\AddOns\oUF\events.lua:48: in function <Interface\AddOns\oUF\events.lua:46>
(tail call): ?

Locals: (*temporary) = <unnamed> {
 0 = <userdata>
}
(*temporary) = "%s: %i"
(*temporary) = false
(*temporary) = 25
(*temporary) = "string expected, got boolean"
can anyone please explain whats wrong with the formatting and how to fix it?

shouldve pasted the actual code from the core file


Code:
if cfg.altpowerbar then		-- alt power bar skinning
			local altpower = CreateFrame('StatusBar', nil, UIParent)
			altpower:SetStatusBarTexture(cfg.powertex)
			altpower:SetStatusBarTexture(0.6, 0.6, 0.6)
			altpower:SetSize(160, 4)
			altpower:SetPoint('TOP', 0, -136)
			
			local bg = altpower:CreateTexture(nil, 'BACKGROUND')
			bg:SetAllPoints(altpower)
			bg:SetTexture(0.1, 0.1, 0.1, 0.75)
			altpower.bg = bg
			
			local value = altpower:CreateFontString(nil, 'OVERLAY')
			value:SetFont(cfg.font, cfg.fontsize, cfg.fontflag)
			value:SetPoint('TOP', altpower, 'BOTTOM', 0, -4)
			altpower.value = value
			
			altpower.border = mu.createBorder(altpower)
			altpower.PostUpdate = function(Bar, min, cur, max)
			Bar.value:SetFormattedText('%s%s', Bar.powerName, cur)
			end
			
			self.AltPowerBar = altpower
		end

Last edited by kawe : 09-26-15 at 04:05 AM.
  Reply With Quote
09-25-15, 02:24 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
The second parameter being passed to SetFormattedText at line 242 in the file Interface\AddOns\oUF_Mu\core\layout.lua is a boolean (true/false) insted of text.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
09-26-15, 03:04 AM   #3
kawe
A Cyclonian
 
kawe's Avatar
Join Date: Sep 2009
Posts: 40
yes, but how is it that this worked before? (5.x & prev)

and how should i format it then? %s%s? %d %i? it only shows the current alt.power value

fixed, seems that %s%s did the trick for correct display, thx for reply

Last edited by kawe : 09-26-15 at 05:19 AM. Reason: found solution
  Reply With Quote
09-27-15, 10:04 PM   #4
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
Just wanted to quickly point out that the text might look a little better with a space or two between the values and some brackets:

Code:
Bar.value:SetFormattedText('%s (%s)', Bar.powerName, cur)
Also, if you'd like to ensure that this function is only called when the value of 'cur' is a string, replace the call with this:

Code:
if (type(cur) == 'string') then
  Bar.value:SetFormattedText('%s (%s)', Bar.powerName, cur);
end
__________________
__________________

Last edited by Aanson : 09-27-15 at 10:08 PM.
  Reply With Quote
09-28-15, 05:38 AM   #5
kawe
A Cyclonian
 
kawe's Avatar
Join Date: Sep 2009
Posts: 40
alright, that is indeed better.

my thanks
  Reply With Quote
09-29-15, 07:20 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
Originally Posted by Aanson View Post
Also, if you'd like to ensure that this function is only called when the value of 'cur' is a string, replace the call with this:

Code:
if (type(cur) == 'string') then
  Bar.value:SetFormattedText('%s (%s)', Bar.powerName, cur);
end
This only stops the error from occurring, but doesn't solve the underlying problem. A better question is why does the entry have false stored in it rather than a usable value? This is an example of a logic error rather than a syntax one since something is corrupting data and causing other code to raise errors.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
09-29-15, 11:53 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Assuming the error is ocurring in this code:
Code:
altpower.PostUpdate = function(Bar, min, cur, max)
	Bar.value:SetFormattedText('%s%s', Bar.powerName, cur)
end
.... then your "solution" just makes this function do nothing, since the cur value is always a number (but you're checking to see if it's a string) and isn't addressing the problem anyway, since your error indicates that Bar.powerName is the boolean, not cur.

The underlying problem is that the return values from UnitAlternatePowerInfo have apparently changed since that part of oUF was last updated. According to Blizzard code, the current return values are:

Code:
barType, minPower, startInset, endInset, smooth, hideFromOthers, showOnRaid, opaqueSpark, opaqueFlash, anchorTop, powerName, powerTooltip, costString, barID = UnitAlternatePowerInfo(unit)
...but oUF is assuming something in the middle isn't there, and assigning to "powerName" what is actually the "anchorTop" value by Blizzard's naming. I've opened a pull request on GitHub, but in the meantime, you can apply the fix by opening oUF/elements/altpowerbar.lua and adding another underscore in the list of values from UnitAlternatePowerInfo, like so:

Code:
	local barType, min, _, _, _, _, _, _, _, _, powerName, powerTooltip = UnitAlternatePowerInfo(unit)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
09-30-15, 08:47 AM   #8
kawe
A Cyclonian
 
kawe's Avatar
Join Date: Sep 2009
Posts: 40
well thx for the explanation, my solution was that the error disappeared en the bar skinning worked again :P

before i go into depths with lua and/or oUF i should put more effort into programming and learning lua, which, to this day has not happend

so i am mostly editing and trying to "fix" issues with some addons through my basic knowledge and of course wow interface forums

but oUF_Mu hasn't been updated since 5.4 and some important elements are not working properly.

thx anyway for reply's, learned a little bit more
  Reply With Quote
10-02-15, 05:38 AM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by kawe View Post
before i go into depths with lua and/or oUF i should put more effort into programming and learning lua, which, to this day has not happend
Writing Lua *is* programming. There's no need to go read a textbook or take a class, unless you're really bad at self-teaching. Just keep doing what you're doing -- what you're doing *is* putting effort into learning. Read code, figure out how it works, figure out how to change it. If you don't understand how something works, you can ask, or you can just try something and see what happens.

Remember that you're working with a UI addon for a video game, not the nuclear football. It's okay to make mistakes, and you'll (probably) learn more by trying something and screwing up than you will be having someone else tell you what to do. Of course there's nothing wrong with asking questions, but don't be afraid to experiment either.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 10-02-15 at 05:45 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » bad argument


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