Jump to content

Colorcodes in Labels


BriGhtx3

Recommended Posts

Posted

Kenix, your work but color codes appears and not colors.

Cadu12, I've seen that r, g, b is nil then it sets r = 255, g = 255, b = 255.

My code:

function guiCreateColorLabel ( ax, ay, bx, by, str, relative, parent ) 
    local pat = "(.-)#(%x%x%x%x%x%x)" 
    local s, e, cap, col = str:find(pat, 1) 
    local last = 1 
    while s do 
        if cap == "" and col then r, g, b = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), 
        tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) 
        end 
        last = e + 1 
        s, e, cap, col = str:find( pat, last ) 
    end 
    if r == nil then r = 211 end 
    if g == nil then g = 211 end 
    if b == nil then b = 211 end 
    if last <= #str then 
        cap = str:sub( last ) 
        string = string.gsub(cap,'%x%x%x%x%x%x','') 
        label = guiCreateLabel ( ax, ay, bx, by, string, relative, parent ) 
        guiLabelSetColor ( label, r, g, b ) 
        return label 
    end 
end 

Posted

*sigh*

to use colored labels you need to use labels at first, not chatbox.

for chatbox colorcodes just set colorcoded argument to true, and include hex color codes, all you need to do.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...