Color and Formatting Codes
Now that you have a handle on how to build rooms, objects, and NPCs, let’s see how to make text look the way you want it to. You can format and color it. Currently the VME doesn’t support all the ASCII characters but if we get enough people wanting this ability it will be added.
The Escape Character
There are always two parts to a formatting command. The first part we call the escape character which is the & character. Thus all formatting and color commands would look as follows:
&<color or formatting command>
Formatting Codes
As you may have noticed, the string fields on the VME are formatted in an English paragraph style. What that means is all text is formatted with the following rules:
- All leading blanks are stripped away. For room descriptions three leading spaces are added. This way, we ensure a consistent formatting of the displayed room descriptions.
- Spaces and blanks (newlines) are contracted to single spaces yielding a correctly ‘wrapped’ text for any sentence.
- If a ‘.’ is encountered followed by a blank, a total of two spaces are inserted after the ‘.’.
These formatting rules are great for normal descriptions and extras; but, what if you want to make a sign or a map? You don’t always want wrapped text. If the server wrapped your sign it would turn out looking like a jumble of punctuation in the form of a paragraph.
Formatting and Color Codes Summary
| Code | Description |
|---|---|
&& | Used to make an ampersand & character instead of an escape code |
&l | Text from this point forward will not be formatted by the server. It will be interpreted literally with newlines, spaces, etc. Useful when making a sign or a map |
&f | Text from this point forward will be formatted by the server. This option is the reverse of &l and is default on any section of text |
&s<#> | Force a single space character (or <#> if specified, may come in handy instead of having to toggle formatting) |
&n | Force a new line, very handy instead of toggling the &l formatting switch |
&h | Clears the screen if the terminal of the user supports it |
&x | A file new line used for split so that you can split a file into lines |
&c<color> | Set the foreground color |
&b<color> | Set the background color |
&[<color>] | Set a preset foreground and background color |
&{w} | Start web-only content block (only shown to web client users) |
&{/w} | End web-only content block |
Formatting Code Descriptions and Examples
&&
If you want a single & you must let the VME know that you don’t want a formatting or a color code. You do this by doubling the & sign. Here are a couple examples:
| Text | Result |
|---|---|
&& | & |
&&&& | && |
&&&&&& | &&& |
&l
When you want to turn off the formatting you use this formatting code. Everything after the &l will be shown exactly as you put it in the string.
&l
* *
* *
* *
*
* *
* *
* *
&f
The formatted text as we have already said is default. If you want to turn the formatted text back on after some literal text like a sign or a map you just use the &f code. The following is an example of some literal text followed by a short bit of formatted text.
&l
* *
* *
* *
*
* *
* *
* *
&fThe X marks the spot!
&s<#>
If you want to input extra spaces in a sentence without using the &l you can add them one at a time or multiple by using the &s code.
This sentence has 10 spaces&s10before the first word before.
&n
If you want to input some blank lines without using the literal code you can add a &n for each line you want.
This sentence&n&n&n would look like this:
This sentence
would look like this:
&x
The line break is made for use with the DIL language. You will not need it to do regular text formatting. It was added so a DIL could split a string that is loaded from a file. If you don’t understand the following example don’t worry it is explained more in the DIL reference.
mystrlist := split(string, "&x");
&h
On terminals that can handle it the &h will clear the screen. If you wanted a sign that would clear the screen before displaying when a character looked at it would look like this:
&h&l
* *
* *
* *
*
* *
* *
* *
&fThe X marks the spot!
&{w} and &
These codes create web-only content blocks. Text between &{w} and &{/w} is only shown to players using the web client - telnet users will not see it.
This is useful for adding clickable links, images, or other HTML-specific content that wouldn’t work on telnet clients.
extra {}
"A notice board hangs on the wall.
&{w}
<a href='https://example.com/rules'>Click here for guild rules</a>
&{/w}"
Telnet users see only “A notice board hangs on the wall.” while web users also see the clickable link.
Color Code Descriptions and Examples
&c and &b
In order to allow you to change the colors there are two codes. One is for the foreground color (&c) and the other is for the background color (&b). Both support an optional modifier for brightness or variation. They have the forms as follows:
&c<modifier><color>
&b<modifier><color>
It is important to set both the foreground and background color because if a player has their default background color set to blue and you use blue as a foreground color it will make the letters invisible to the player. It is also important to set the colors back to the default color when done. This is done by using the following command:
&[default]
Note: The
&[default]command will be described in the next section. It is enough to know for now that it will return the player’s colors to their default colors.
Before we give some color examples we should define the symbols for brightness and the symbols for each color and what they are.
Color Codes
| Code | Color |
|---|---|
n | Black |
r | Red |
g | Green |
y | Yellow |
b | Blue |
m | Magenta |
c | Cyan |
w | White |
o | Orange |
p | Pink |
Modifier
+= Bright-= Variation (an alternative shade of the color)- No prefix = Normal
Sample Color Codes
| Code | Description |
|---|---|
&cb&bw | Blue foreground on white background |
&c+g&bn | Bright green foreground on black background |
&c+w&br | Bright white foreground on red background |
&c+w&bn | Bright white foreground on black background |
&c-r&bn | Variation red foreground on black background |
Xterm 256 Color Support
For more precise color control, xterm 256 colors are supported:
| Code | Description |
|---|---|
&c#NNN | Foreground xterm 256 color by number (0-255) |
&b#NNN | Background xterm 256 color by number (0-255) |
&c[name] | Foreground by xterm 256 color name |
&b[name] | Background by xterm 256 color name |
Example: &c#196 or &c[cherrytomato] for bright red foreground.
See the Xterm 256 Color Reference for a complete list of color codes and names.
Note: Players on ANSI terminals that do not support xterm 256 colors will automatically receive the nearest ANSI 16-color equivalent. No special handling is required in zone files.
&[<color>]
As we have said in the previous section, if you’re not careful you can make your text not visible to the player by inadvertently setting the foreground to the same color as the player’s background. To make it easy for you to change how the color looks and even match it with the way players have their colors set already, we created colors that the players can set and you can use. The VME comes with a default list of colors which can be added to by either the color.def or even by a DIL program online. The default colors are as follows:
| Color Name |
|---|
| death |
| default |
| exit |
| group |
| hit_me |
| hit_opponent |
| hit_other |
| immort_descr |
| immort_title |
| log |
| mail_header |
| miss_me |
| miss_opponent |
| miss_other |
| nodam_me |
| nodam_opponent |
| nodam_other |
| npc_descr |
| npc_title |
| obj_descr |
| obj_title |
| paging |
| pc_descr |
| pc_title |
| prompt |
| respond |
| room_descr |
| room_title |
| say_other |
| say_self |
| shield_me |
| shield_opponent |
| shield_other |
| shout_other |
| shout_self |
| social_other |
| social_self |
| spells |
| tell_group |
| tell_imm |
| tell_other |
| tell_self |
| time |
| weather |
| whisper |
| who |
| who_guild |
| who_inv |
| who_name |
| who_title |
| wiz |
| xpgain |
To use these colors all you have to do is use the following formatting command:
&[color]
The color that will be shown is the color that the player has set for the color in question. If for example the player has his or her ‘death’ color set to bright red with a black background and you have a description as follows:
descr
"This is a &[death]death&[room_descr] room"
The description would be in the player’s ‘room_descr’ color while the word death would be in his or hers ‘death’ color. You should note we had to set the color back to the room description color so that the rest of the description was not in the ‘death’ color.
To change the player’s color to the default output color (which is the color that is used when no color is specified by the server) then you use default. You probably won’t use this in normal zone building but it is very important to know it exists when you start making spells, skills, and commands with DIL.