Difference between revisions of "Color Codes"

From WolfWiki
Jump to: navigation, search
m (little changes)
Line 6: Line 6:
 
'''Produces:''' <font color="red">red</font> <font color="green">green</font> <font color="blue">blue</font><br>
 
'''Produces:''' <font color="red">red</font> <font color="green">green</font> <font color="blue">blue</font><br>
 
==Codes list==
 
==Codes list==
The image below depicts the colours the characters produce, except '''^0''' which, stands for black. Notice that some letters and digits produce the same colour.<br><br>
+
The images below depicts the colours the characters produce. Notice that some letters and digits produce the same colour.<br><br>
http://velocity.lunarpages.com/images/colors.jpg
+
http://velocity.lunarpages.com/images/colors.jpg<br>
 +
http://etpro.poohunter.de/etcolors.jpg
 +
The blue one in the middle which is crumpled is supposed to be the &gt; sign.
  
 
==Code Filtering==
 
==Code Filtering==

Revision as of 17:36, 12 November 2005

What are they?

Colour codes are used to add colour to text. They were introduced in Quake III Arena and are available in most Q3 engine based games, including Enemy Territory. They can be used with most text that gets displayed ingame, such as player names, chat or notices.

Usage: a dash character (^) followed by another character. Each character produces a different colour.
Example: ^1red ^2green ^4blue
Produces: red green blue

Codes list

The images below depicts the colours the characters produce. Notice that some letters and digits produce the same colour.

http://velocity.lunarpages.com/images/colors.jpg
http://etpro.poohunter.de/etcolors.jpg The blue one in the middle which is crumpled is supposed to be the > sign.

Code Filtering

Here is a little php script that can be used to parse colorcodes and return the HTML formatted, colored string:

// ©2003 Deus@pooHunter.de
// This script uses the original RGB-values that were used in RtCW:OSP which I received directly from rhea.
// AFAIK these RGB values did not change in ET/ETPro 
function parse_gamecolors($string)
{
	$string = ereg_replace("(\^)?$", "^", $string);
	$string = ereg_replace("\^\^", "&#94^", $string);
	$string = ereg_replace("(\^)?$", "", $string);
	$string = ereg_replace("\^<", "^|", $string);
	$string = ereg_replace("\<", "<", $string);
	$string = ereg_replace("\^>", "^^", $string);
	$string = ereg_replace("\>", ">", $string);
	$string = ereg_replace("\^\^", "^>", $string);
	$string = "<font color=\"#FFFFFF\">".$string."</font>";

	$color_def = array
	(
		0  => "#000000",	1  => "#FF0000",	2  => "#00FF00",	3  => "#FFFF00",
		4  => "#0000FF",	5  => "#00FFFF",	6  => "#FF00FF",	7  => "#FFFFFF",
		8  => "#FF7F00",	9  => "#7F7F7F",	10 => "#BFBFBF",	11 => "#007F00",
		12 => "#7FFF00",	13 => "#00007F",	14 => "#7F0000",	15 => "#7F4000",
		16 => "#FF9933",	17 => "#007F7F",	18 => "#7F007F",	19 => "#007F7F",
		20 => "#7F00FF",	21 => "#3399CC",	22 => "#CCFFCC",	23 => "#006633",
		24 => "#FF0033",	25 => "#B21919",	26 => "#993300",	27 => "#CC9933",
		28 => "#999933",	29 => "#FFFFBF",	30 => "#FFFF7F"
	);

	$color_chardef = array
	(
		"#000000"	=> array (	0 => "0",	1 => "P",	2 => "p"	),
		"#FF0000"	=> array (	0 => "1",	1 => "Q",	2 => "q"	),
		"#00FF00"	=> array (	0 => "2",	1 => "R",	2 => "r"	),
		"#FFFF00"	=> array (	0 => "3",	1 => "S",	2 => "s"	),
		"#0000FF"	=> array (	0 => "4",	1 => "T",	2 => "t"	),
		"#00FFFF"	=> array (	0 => "5",	1 => "U",	2 => "u"	),
		"#FF00FF"	=> array (	0 => "6",	1 => "V",	2 => "v"	),
		"#FFFFFF"	=> array (	0 => "7",	1 => "W",	2 => "w"	),
		"#FF7F00"	=> array (	0 => "8",	1 => "X",	2 => "x"	),
		"#7F7F7F"	=> array (	0 => "9",	1 => "Y",	2 => "y"	),
		"#BFBFBF"	=> array (	0 => ":",	1 => "Z",	2 => "z",
						3 => ";",	4 => "[",	5 => "{"	),
		"#007F00"	=> array (	0 => "<",	1 => "\\",	2 => "|"	),
		"#7FFF00"	=> array (	0 => "=",	1 => "]",	2 => "}"	),
		"#00007F"	=> array (	0 => ">"					),
		"#7F0000"	=> array (	0 => "?"					),
		"#7F4000"	=> array (	0 => "@",	1 => "`"			),
		"#FF9933"	=> array (	0 => "A",	1 => "a",	2 => "!"	),
		"#007F7F"	=> array (	0 => "B",	1 => "b"			),
		"#7F007F"	=> array (	0 => "C",	1 => "c",	2 => "#"	),
		"#007F7F"	=> array (	0 => "D",	1 => "d",	2 => "$"	),
		"#7F00FF"	=> array (	0 => "E",	1 => "e",	2 => "%"	),
		"#3399CC"	=> array (	0 => "F",	1 => "f",	2 => "&"	),
		"#CCFFCC"	=> array (	0 => "G",	1 => "g",	2 => "'"	),
		"#006633"	=> array (	0 => "H",	1 => "h",	2 => "("	),
		"#FF0033"	=> array (	0 => "I",	1 => "i",	2 => ")"	),
		"#B21919"	=> array (	0 => "J",	1 => "j"			),
		"#993300"	=> array (	0 => "K",	1 => "k",	2 => "+"	),
		"#CC9933"	=> array (	0 => "L",	1 => "l",	2 => ","	),
		"#999933"	=> array (	0 => "M",	1 => "m",	2 => "-"	),
		"#FFFFBF"	=> array (	0 => "N",	1 => "n",	2 => "."	),
		"#FFFF7F"	=> array (	0 => "O",	1 => "o",	2 => "/"	)
	);
		
	for ($cd1 = 0; $cd1 < 31; $cd1++)
	{
		for ($cd2 = 0; $cd2 < count($color_chardef[$color_def[$cd1]]); $cd2++)
		{
			$string = str_replace("^". $color_chardef[$color_def[$cd1]][$cd2], "</FONT><FONT COLOR=\"" . $color_def[$cd1] . "\">", $string);
		}
	}
	return $string;
}