Tags:
Code:
return format('|cff%02x%02x%02x%s', r, g, 0, healthcurrent)
Very minor, but there's no need to spend CPU time turning that 0 into 00 over and over; just hardcode the 00:
Code:
return format('|cff%02x%02x00%s', r, g, healthcurrent)
You could even take that further and avoid that second
format call entirely:
Code:
local color
if healthcurrent < healthmax then
color = '|cffb40000'
else
color = '|cff00b400'
end
if healthcurrent >= 1000000 then
healthcurrent = format('%.1fm', healthcurrent/1000000)
elseif healthcurrent >= 1000 then
healthcurrent = format('%.0fk', healthcurrent/1000)
end
return color .. healthcurrent
================================
Code:
powertype = select(2,UnitPowerType(u))
select is a complete waste of CPU time in 99.9999999999999999% of situations, including this one. Use a throwaway variable instead:
Code:
local powercurrent, powertype, pr, pg, pb, _
_, powertype = UnitPowerType(u)
...or just the less intuitive but equally effective method of overwriting the variable with itself:
Code:
powertype, powertype = UnitPowerType(u)
================================
Code:
elseif powertype == 'FOCUS' then
pr, pg, pb = 255, 128, 65
elseif powertype == 'ENERGY' then
pr, pg, pb = 255, 255, 0
elseif powertype == 'RUNIC_POWER' then
pr, pg, pb = 0, 209, 255
else
pr, pg, pb = 255, 0, 0
end
In all these cases, those are the default colors for those power types, so rather than a list of "elseif" conditions and hardcoded values, just
fetch the default colors:
Code:
else
local c = PowerBarColor[powertype]
pr, pg, pb = c.r * 255, c*g * 255, c*b * 255
end