Game Development Community

Text Color

by AIDan · in Torque Game Engine · 09/03/2001 (9:53 am) · 6 replies

Hi

To find errors more quickly, I want to know how to change the text color in the console.

greetings
Daniel

#1
02/27/2010 (7:30 am)
Paste the following code into a new script and add the script name as an exec statement in init.cs. Open the console (~) and execute the function: ConsoleColorTest();

Each line will display the numeric color value. Some are more useful for debug text than others.

//------------------
// Color Test
//------------------
function ConsoleColorTest()
{
   echo("c0)  c0 Torque Poweredcr");
   echo("c1)  c1 Torque Poweredcr");
   echo("c2)  c2 Torque Poweredcr");
   echo("c3)  c3 Torque Poweredcr");
   echo("c4)  c4 Torque Poweredcr");
   echo("c5)  c5 Torque Poweredcr");
   echo("c6)  c6 Torque Poweredcr");
   echo("c7)  c7 Torque Poweredcr");
   echo("c8)  c8 Torque Poweredcr");
   echo("c9)  c9 Torque Poweredcr");
}
#2
03/02/2010 (11:16 am)
these do not work ... it just prints out;

c0) c0 Torque Poweredcr
c1) c1 Torque Poweredcr
c2) c2 Torque Poweredcr
c3) c3 Torque Poweredcr
c4) c4 Torque Poweredcr
c5) c5 Torque Poweredcr
c6) c6 Torque Poweredcr
c7) c7 Torque Poweredcr
c8) c8 Torque Poweredcr
c9) c9 Torque Poweredcr
#3
03/02/2010 (2:07 pm)
Try:
echo("Hello");
error("Goodbye");
#4
03/12/2012 (4:59 am)
Here is the correct way of displaying the colors you want to see using the function you created.

function ConsoleColorTest()  
{  
   echo("\c0 c0)  c0 Torque Poweredcr");  
   echo("\c1 c1)  c1 Torque Poweredcr");  
   echo("\c2 c2)  c2 Torque Poweredcr");  
   echo("\c3 c3)  c3 Torque Poweredcr");  
   echo("\c4 c4)  c4 Torque Poweredcr");  
   echo("\c5 c5)  c5 Torque Poweredcr");  
   echo("\c6 c6)  c6 Torque Poweredcr");  
   echo("\c7 c7)  c7 Torque Poweredcr");  
   echo("\c8 c8)  c8 Torque Poweredcr");  
   echo("\c9 c9)  c9 Torque Poweredcr");  
}
#5
03/12/2012 (12:06 pm)
Resurrection correction - nice!

You have to use the escape string sequence as Jose indicated - the backslash character '\'. Benster may have included them in the first comment and example, but there is a website bug were they get removed if a post is edited. The 'escape sequence' functionality can also be used with a MLText Control.
#6
03/12/2012 (12:09 pm)
And to go along with Daniel's suggestion you can also you warn() in place of echo() or error().
echo("Hello");
warn("Watch out!");  
error("Goodbye");