Skip to content

Change Text/Font color?

Is there one built in with EE now, and if not could somebody recommend one?

They used to look like.

SendMessageToPC(oPC, "<LimeGreen>Your pants are on fire.<^c>");


* Is there a way to just search Builders- Scripting? I cant find it if there is.

Comments

  • ForSeriousForSerious Member Posts: 466
    I've seen what you have there before. It would need an include script defining 'LimeGreen'.
    For searching, I'd search for that closing tag '</c>' but maybe you'd find more searching for something like '<cþ >'.

    The built in way is:
    #include "x3_inc_string"
    // FILE: x3_inc_string      FUNCTION: StringToRGBString()
    //
    // This function will make sString be the specified color
    // as specified in sRGB.  RGB is the Red, Green, and Blue
    // components of the color.  Each color can have a value from
    // 0 to 7.
    // Ex: red   == "700"
    //     green == "070"
    //     blue  == "007"
    //     white == "777"
    //     black == "000"
    // The STRING_COLOR_* constants may be used for sRGB.
    string StringToRGBString(string sString, string sRGB)
    

    Another way to do it is through custom tokens. This works well in conversations. Set these in OnModuleLoad:
    SetCustomToken(100, "</c>"); // CLOSE tag
        SetCustomToken(101, "<cþ  >"); // red
        SetCustomToken(102, "<c þ >"); // green
        SetCustomToken(103, "<c  þ>"); // blue
        SetCustomToken(104, "<c þþ>"); // cyan
        SetCustomToken(105, "<cþ þ>"); // magenta
        SetCustomToken(106, "<cþþ >"); // yellow
        SetCustomToken(107, "<c   >"); // black
        SetCustomToken(108, "<c¥  >"); // dark red
        SetCustomToken(109, "<c ¥ >"); // dark green
        SetCustomToken(110, "<c  ¥>"); // dark blue
        SetCustomToken(111, "<c ¥¥>"); // dark cyan
        SetCustomToken(112, "<c¥ ¥>"); // dark magenta
        SetCustomToken(113, "<c¥¥ >"); // dark yellow
        SetCustomToken(114, "<c¥¥¥>"); // grey
        SetCustomToken(117, "<cŒŒŒ>"); // dark grey
        SetCustomToken(115, "<cþ¥ >"); // orange
        SetCustomToken(116, "<cþŒ >"); // dark orange
        SetCustomToken(117, "<cÚ¥#>"); // brown
        SetCustomToken(118, "<c† >"); // dark brown
    

    Then of course, you can do it the way you mentioned. Make an include script that defines the colors:
    const string RED = "<cþ  >";
    
    I'll let you figure out how to set the colors.
    Here are all the symbols used in x3_inc_string going from lowest to highest:
    fw®°Ìþþþ
    As you can see though, there's a bunch of other symbols that can be used. Maybe I'll look up and see if there's a reference somewhere if I have time.
  • BuddywarriorBuddywarrior Member Posts: 62
    That's it! Thank you.
  • ProlericProleric Member Posts: 1,316
    There's also the StringToRGBString() function.
  • ForSeriousForSerious Member Posts: 466
    I forgot to mention that you can also use that code in things like item descriptions like this:
    <c† >Text to be made brown</c>
  • ProlericProleric Member Posts: 1,316
    edited October 2021
    ... and as of 8193.32, in scripts, you can enter those codes as hex escape sequences e.g. \xFF for greater legibility.
    Post edited by Proleric on
  • TarotRedhandTarotRedhand Member Posts: 1,481
    If you use StringToRGBString() but are not sure of the actual colour or the code to use, I made a simple html document to aid with that - Colours and Codes for StringToRGBString() - that matches the codes to the colours.

    TR
  • GenisysGenisys Member Posts: 37
    // Here are SOME of the working color constants...
    
    // Skip 1 Line (Go to the line directly after this one!)
    const string NEW_LINE = "\n";
    
    // 2 Carriage Returns... (Go to the 2nd line after this one)
    const string SKIP_LINE = "\n\n";
    
    // Skip 2 Lines! (Go to the 3nd line after this one)
    const string DOUBLE_SKIP_LINE = "\n\n\n";
    
    // YOU MUST CLOSE EACH STRING WITH COLOR WITH THIS!
    const string CLOSE = "</c>";
    
    const string RED = "<cüL@>";
    const string WHITE = "<cüüü>";
    const string BLUE = "<c=Tý>";
    const string GOLD = "<cæË*>";
    const string LIME = "<cOüO>";
    const string GREEN = "<c$Ü$>";
    const string ORANGE = "<cü¥>";
    const string PINK = "<cý±ý>";
    const string CYAN = "<c~öö>";
    const string LIGHTGREY = "<cññý>";
    const string GREY = "<cËÏ×>";
    const string PURPLE = "<cçé>";
    const string MAGENTA = "<cç)ç>";
    const string TURQUOISE = "<c*äÍ>";
    const string BLOOD = "<cÍ>";
    const string TAN = "<cüá¢>";
    const string ROSE = "<cá±Å>";
    const string LIGHTPINK = "<cýáý>";
    const string BROWN = "<c¯xE>";
    const string ARMYGREEN = "<cLs4>";
    const string MONEY = "<c6a9>";
    const string SLATE = "<c}}©>";
    const string DEEPPURPLE = "<c}}©>";
    const string DARKPURPLE = "<c}}©>";
    const string DARKBROWN = "<cgR3>";
    const string ROYALBLUE = "<cQø>";
    const string DEEPBLUE = "<cÅ>";
    const string NAVYBLUE = "<c¥>";
    const string BABYBLUE = "<c¢Ãý>";
    const string LIGHTBLUE = "<cOzý>";
    const string ICEBLUE = "<cçëü>";
    
    // Here is an example function to use them (YOU NEED TO CODE THE REST)
    
    // Returns sMsg in nColor...
    // 1 = Red / 2 = White / 3 = Blue / etc....  <<< You need to finish this!
    // Contine # = ????....
    string ColorTextMsg(string sMsg, int nColor = 1);
    string ColorTextMsg(string sMsg, int nColor = 1){
    
     switch(nColor){
       case 1: return RED + sMsg + CLOSE;
       case 2: return WHITE + sMsg + CLOSE;
       case 3: return BLUE + sMsg + CLOSE;
    
       // etc.... (Continue with case 4: ... etc)
     }
     return RED + sMsg + CLOSE;  // Default return RED
    }
    


    This should be enough code to help you make a custom function for that purpose...

    Hope that was helpful. ^.^
  • BuddywarriorBuddywarrior Member Posts: 62
    a great resource, thank you Genisys
  • TarotRedhandTarotRedhand Member Posts: 1,481
    Apart from the scripting part, there is another thing to consider (other than colour blindness). That is will it actually be readable against the intended background. This can be more of a problem with exterior areas for obvious reasons (green text over grass!!!). So if you intend to use coloured text, test it first to see if it is actually readable.

    TR
Sign In or Register to comment.