Thread Tools Display Modes
Prev Previous Post   Next Post Next
07-30-09, 01:39 PM   #12
celebros
A Deviate Faerie Dragon
 
celebros's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 12
Originally Posted by Heimdall View Post
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
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » STUF Lua editor


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