Yoshi-Networks

Color label

Mar 4th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. function guiCreateColorLabel ( ax, ay, bx, by, str, relative, parent )
  2. local pat = "(.-)#(%x%x%x%x%x%x)"
  3. local s, e, cap, col = str:find(pat, 1)
  4. local last = 1
  5. while s do
  6. if cap ~= "" and col then r, g, b = tonumber( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ),
  7. tonumber( "0x"..col:sub( 5, 6 ) ) )
  8. end
  9. last = e + 1
  10. s, e, cap, col = str:find( pat, last )
  11. end
  12. if r == nil then r = 211 end
  13. if g == nil then g = 211 end
  14. if b == nil then b = 211 end
  15. if last <= #str then
  16. cap = str:sub( last )
  17. string = string.gsub(cap,'%x%x%x%x%x%x','')
  18. label = guiCreateLabel ( ax, ay, bx, by, string, relative, parent )
  19. guiLabelSetColor ( label, r, g, b )
  20. return label
  21. end
  22. end
Advertisement
Add Comment
Please, Sign In to add comment