View Single Post
12-12-13, 06:46 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Actually on second glance, I think this is your problem:

Code:
("|cFF%.2x%.2x%.2x%s|r"):format(color[1] * 255, color[2] * 255, color[3] * 255, count)
%.2x does not guarantee a 2-digit result; it guarantees a result with no more than 2 digits after the decimal point. You want to use %02x instead.

For example, format("%02f", 10 / 3) == "03.33333333333333333", but format("%.2f", 10 / 3) == "3.33". So, if your color values are 1, 0.5, and 0 then you're converting them into ff (ok), 99 (ok) and 0 (not ok) to end up with "|cffff990<<count>>|r" which isn't a valid color code. Technically you are producing a valid color code when combined with your count, since 1, 2, and 3 are valid hexadecimal values -- "|cffff9903|r" -- but then you don't have any text to display.

Also, ("text"):format(...) is the slowest possible method of formatting a string. Use format("text", ...) instead:

Code:
return format("|cff%02x%02x%02x%s|r", color[1] * 255, color[2] * 255, color[3] * 255, count)
__________________
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 : 12-12-13 at 06:48 PM.
  Reply With Quote