Coloring your server name! (and console text too)

Coloring your server name! (and console text too)

I'm at least 40% sure that when you first tried to figure out how to get a colored title for your server, you found this 2011 post (among other results but this was the first one).

I thought it would be better to go slightly more in-depth, update it to recent versions and mention other uses.

Let's start with this from the get-go: You cannot color your player name, nor chat text (yourself). If it was possible in older versions, good, but you cannot do so since around 2.0 I think.



There are two ways of text coloring you can follow:

a. caret colors

One of them is using numbers from 0 to 7 prepended by the ^ symbol (that is, from ^0 to ^7).
(From 2.2.9, this is expanded to be from ^0 through ^9, then ^A through ^F)

This is the easiest way to color your server name, but doesn't show on the in-game server list proper, while it does on the website version of the master server.
On top of that, this method uses up two characters which do count for the maximum amount of characters your server name may have.

Fortunately, these are useful for character select entries! After signaling a color, all text afterwards will be colorized with it.

b. ascii symbols

SRB2 uses a funny little trick for colorizing text!
Whenever it needs to know what to colorize and what color, SRB2 looks for specific symbols that you can't normally type... sometimes. These symbols are used as "color codes", "hex codes" or just "symbols".
Ever wondered why your "echo" script, your Lua lump or anything with a weird symbol would colorize the whole line? That's why.

You can find a grid of these symbols here. What color pertains to each symbol can be found below.



Now, before explaining how to color your console text or your server name, here are the colors and color codes available to you:


The colors​

SRB2 and Kart use a different color set.
srb2colors.png
kartcolors.png

Colors 80 through 87 are visible in the server title - All other colors would either appear as the default black or truncate the rest of the name.
For caret codes, remember to replace x8 with ^.



The hex codes​

srb2colorgrid.png

Every increment of 0x01 changes the color, while every increment of 0x10 increases the text's transparency.
Neither SRB2 nor Kart support transparency in the server name, resulting in white text in the in-game server browser or a blank name in the web browser.
For caret codes, read above.

Consequently, these hex numbers correspond to the numbers between 128 (0x80) through 255 (0xff).

Know that, with either some trickery, an hex editor and/or patience, you can get the symbol that pertains to a specific code. Or you can use the symbol grid mentioned above. :(


How to apply all of this​

As explained, to add colors to your server name you use symbols or a caret code.
To do so, you must execute the command from a text file, be it from its own text file or by autoexec.cfg (read below).

Apologies in advance, as my UI is in spanish.

Step 1:
Begin by creating a text file in your SRB2 folder, and call it however you want.
ShqOG0H.png

We will execute this file in SRB2, so don't make it too long.
Once you create it, open it.
This pseudo-tutorial has images for both Notepad and Notepad++. Other programs may have encoding functionality, but how to do so is out of the scope of this guide.

Step 2:
This is VERY important: Make sure the encoding of the file is ANSI!
If the encoding is not ANSI, the program will interpret those symbols as something else, and the formatting will get screwed up, preventing SRB2 from reading it as you want.

In Notepad, select the file menu and click "Save As...", and you'll be given a prompt for a filename. Right next to the save button, you have an "Encoding" drop down menu. Select ANSI, and save the text file.
vuRbgcD.png


In Notepad++, there's an "Encoding" tab at the top of the window. Select "Encode in ANSI" from there. Save the file after that.
SUeG1h7.png


Step 3:
Now that we have our ANSI text file, it's time to start colouring!
Pick some colors, and as you type your server name, add the relevant symbols behind the text you want to color.
For example, if you want your server name to look like:
C0S5DmF.png

(the words "The" and "Of" being gray, while "Sun" is yellow and "Nature" is green)
You would type in your text file:
Code:
servername "†The ‚Sun †Of ƒNature"
"†" represents gray, "‚" represents yellow and "ƒ" represents green.
The symbols will color anything in front of them.

Step 4:
Now that we have our file, save it and start SRB2.
In the console, type "exec" followed by a space and the entire file name of the file you created. Done!
Now check the "Host server" menu, and you'll see your new colored server name there.
And that's pretty much it!



If the color doesn't work, make sure your text file is encoded in ANSI.
If the server name gets cut off, make it shorter. The server name will truncate after 31 characters.

If you don't feel like reading a huge paragraph here you go:

1) Make a text file
2) Make sure it uses the ANSI encoding
3) Type "servername", add a space then go type your server name, adding the color symbols behind the text you want to color.
3b) Enclose the server name in quotes.
4) Save
5) Execute in SRB2

k there you go

The server name will truncate after 31 characters.
You might want to avoid making every character have a different color, as each symbol occupies 1 character.



For Lua scripting​

It's worth mentioning - You don't need to copy these symbols if you want to print colored text!
Lua can escape special characters via an escape sequence - These always begin with a backslash (\), which says that the following character will be a character that tells Lua what action to take when processing the string.
For escaping symbols, you have two different formats:
  • One of them involve the backslash followed by up to three decimal digits forming a number between 0 to 255. You can use left zeroes to pad out anything less than three digits for readability.
    For example:
    • \065 would escape the character A.
    • \129 would escape a purple color code.
  • The second one involves an hexadecimal escape. A backslash followed by a lowercase x tells Lua the following (hexadecimal) characters are part of the sequence. Anything that doesn't conform to hexadecimal (a space or any other character) will end the sequence and will be written as expected.
    For example:
    • \x41 would escape the character A.
    • \x81 would escape a purple color code.



Final notes​

I've been writing about the master server in present continuous. That's intentional :)

By the way, you can also write the server name command in your autoexec.cfg file! This way your server name will be set everytime you load the game.



And that's pretty much it.
Thanks for reading, have fun, I hope it made sense, and please use it for good, this isn't acceptable
X3Vtc2J.png

this hurts the man
Author
amperbee
Views
7,518
First release
Last update
Rating
5.00 star(s) 2 ratings

Share this resource

Latest reviews

Very helpful and easy to follow. I've been searching the wiki for a while not knowing this topic isn't documented there, and I eventually just decided to search the MB and found this.
Upvote 0
Very helpful! This condenses info from the wiki (as well as some info not yet on the wiki?) into one convenient spot. I learned a thing or two while reading.
Upvote 2
Back
Top