Results 1 to 2 of 2

Thread: Easy way to get HEX codes for colours, like stringColorToRGB()

  1. #1

    Post Easy way to get HEX codes for colours, like stringColorToRGB()

    We need a stringColorToHex() function ideally instead of having to copy in a table of colour indexes associated with their hex codes. I just want this for easier printing of coloured text in the game.
    Code:
    printToAll("This message is about [".. stringColorToHex("Red") .."]Player Red[-] and [".. stringColorToHex("White") .."]Player White[-].", {0.5, 0.5, 0.5})

  2. #2
    Join Date
    May 2016
    Posts
    1,072
    One of Sancho's fine contributions to the function list in the Guides.

    Code:
    function RGBToBracketedHex(rgb)
        if rgb ~= nil then
            return "[" .. string.format("%02x%02x%02x", rgb.r*255,rgb.g*255,rgb.b*255) .. "]"
        else
            return ""
        end
    end
    You would just convert the string to RGB and the RGB to hex =) Cheers

Similar Threads

  1. TTS Easy Manager
    By softbreakers in forum General Discussion
    Replies: 1
    Last Post: 10-28-2016, 09:23 PM
  2. [ADDED] [v7.9] Add Hex Codes to the Color Tint system
    By TheRaven81 in forum Suggestions
    Replies: 4
    Last Post: 09-17-2016, 02:41 PM
  3. Replies: 6
    Last Post: 05-30-2014, 08:23 AM
  4. Replies: 3
    Last Post: 05-26-2014, 06:07 AM
  5. *SUGGESTION* Picking seats and colours
    By Renegade in forum General Discussion
    Replies: 0
    Last Post: 04-30-2014, 03:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •