Originally Posted by Heimdall
Ok, for future reference i've done this ugly code here ( ):
Code:
function(unit, cache)
DB = {}
...
DB[class] = { r=color.r, g=color.g, b=color.b}
...
|
I'm not sure why you're wasting tables here though.
You're creating a DB table, and then one extra table for every class, every time this function is called (yes they will be collected but why waste the cycles in the first place?
Why can't you do:
Code:
for class, color in pairs(RAID_CLASS_COLORS) do
if CLASS == "PALADIN" then
return string.format("cff%02x%02x%02x%s",color.r*255,color.g*255,color.b*255,cache.level)
end
end
Or better yet:
Code:
function (unit, cache)
local _,class = UnitClass(unit)
local color = RAID_CLASS_COLORS[class]
if color then
return string.format("cff%02x%02x%02x%s",color.r*255, color.g*255,color.b*255, cache.level)
else
return cache.level
end
end