Section Index


1. OpenAL || 2. Debugging || 3. String Manipulation || 4. Networking || 5. Console || 6. Device I/O || 7. File I/O
8. Packages || 9. Objects || 10. Event Scheduling || 11. Datablocks || 12. Video / Texturing || 13. Special || 14. Resource Management
15. Scene || 16. Containers and Raycasts || 17. Editors || 18. Build || 19. Time || 20. GUIs || 21. Math


This quick reference guide was taken directly out of The Game Programmer's Guide to Torque by Edward Maurina. It's an outstanding resource - a must for anyone wanting to get serious about programming in Torque.



Contents

Console

call( funcName [ , args ... ] )

Purpose
Use the call function to dynamically build and call a function.

Syntax
funcName
– A string containing the unadorned name of a function to be executed.
args ... - Any arguments that should be passed to the function.

Returns
Returns a string containing the results from the function that is built and called.

See Also
eval

// Prints Hello World
call( "echo" , "Hello" , " ", "World" );



cls( )

Purpose
Use the cls function to clear the console output.

Returns
No return value.



collapseEscape( text )

Purpose
Use the collapseEscape function to replace all escape sequences ('\\xx') with a collapsed version ('\xx').

Syntax
text
– A string, possibly containing escape sequences.

Returns
Returns a copy of text with all escape sequences coverted to an encoding.

See Also
expandEscape

echo( "edo\\t" ); // Prints edo\t

echo( collapseEscape( "edo\\t" ) ); \\ Prints edo^



compile( fileName )

Purpose
Use the compile function to pre-compile a script file without executing the contents.

Syntax
fileName
– A path to the script to compile.

Returns
Returns 1 if the script compiled without errors and 0 if the file did not compile correctly or if the path is wrong. Also, ff the path is invalid, an error will print to the console.

See Also
exec

compile("./main.cs");



deleteVariables( wildCard )

Purpose
Use the deleteVariables function to delete any global variable matching the wildCard statement.

Syntax
wildCard
– A string identifying what variable(s) to delete. All chracters used to create a global are allowed and the special symbol "*", meaning 0 or more instances of any character.

Returns
No return value.

$edo = "cool";

echo( $edo ); // Prints cool

deleteVariables( "$ed*" ); // Delete all globals starting with $ed

echo( $edo ); // Prints "" because $edo was deleted



echo( text [ , ... ] )

Purpose
Use the echo function to print messages to the console.

Syntax
text
– Any valid text string.
... - Any additional valid text string(s).

Returns
No return value.

See Also
error, warn

// Prints This is a test
echo( "This is a test" );



enableWinConsole( enable )

Purpose
Use the enableWinConsole function to tell TGE to create an external console window, either as a separate DOS window or as a new window under OSX/Linux/*NIX.

Syntax
enable
– A boolean. If this value is set to true, a new console window will be created.

Returns
No return value.

Notes
Subsequent calls to this function do nothing. Only one external console is allowed.

enableWinConsole( true ); // Open an external console.



error( text [ , ... ] )

Purpose
Use the error function to print error messages to the console. These messages usually print in red.

Syntax
text
– Any valid text string.
... - Any additional valid text string(s).

Returns
No return value.

See Also
echo, warn

// Prints This is a test
error( "This is a test" );



eval( script )

Purpose
Use the eval function to execute any valid script statement.

Syntax
script
– A string containing a valid script statement. This may be a single line statement or multiple lines.

Returns
Returns the result of executing the script statement.

Notes
If you choose to eval a multi-line statement, be sure that there are no comments or (\\) comment blocks (\**\) embedded in the script string.

See Also
call



exec( fileName [ , nocalls [ , journalScript ] ] )

Purpose
Use the exec function to compile and execute a normal script, or a special journal script.

Syntax
fileName
– A string containing a path to the script to be compiled and executed.
nocalls – A boolean value. If this value is set to true, then all function calls encountered while executing the script file will be skipped and not called. This allows us to re-define function definitions found in a script file, without re-executing other worker scripts in the same file.
journalScript – A boolean value. If this value is set tot true, and if a journal is being played, the engine will attempt to read this script from the journal stream. If no journal is playing, this field is ignored.

Returns
Returns true if the file compiled and executed w/o errors, false otherwise.

Notes
If $Pref::ignoreDSOs is set to true, the system will use .cs before a .dso file if both are found.

See Also
compile

exec( "./main.cs" );



expandEscape( text )

Purpose
Use the collapseEscape function to replace all escape sequences ('\xx') with an expanded version ('\\xx').

Syntax
text
– A string, possibly containing escape sequences.

Returns
Returns a copy of text with all escape sequences expanded.

See Also
collapseEscape

echo( "edo\t" ); // Prints edo^

echo( expandEscape( "edo\t" ) ); \\ Prints edo\t



export( wildCard [ , fileName [ , append ] ] )

Purpose
Use the export function to save all global variables matching the specified name pattern in wildCard to a file, either appending to that file or over-writing it.

Syntax
wildCard
– A string identifying what variable(s) to export. All chracters used to create a global are allowed and the special symbol "*", meaning 0 or more instances of any character.
fileName – A string containing a path to a file in which to save the globals and their definitions. append – A boolean value. If this value is true, the file will be appnded to if it exists, otherwise it will be created/over-written.

Returns
No return value.

	echo("Exporting server prefs");
	export("$Pref::Server::*", "./server/prefs.cs", False);



quit()

Purpose
Use the quit function to stop the engine and quit to the command line.

Returns
No return value.

quit();



warn( text [ , ... ] )

Purpose
Use the warn function to print warning messages to the console. These messages usually yellow or orange.

Syntax
text
– Any valid text string.
... - Any additional valid text string(s).

Returns
No return value.

See Also
warn, error

// Prints This is a test
warn( "This is a test" );


Section Index


1. OpenAL || 2. Debugging || 3. String Manipulation || 4. Networking || 5. Console || 6. Device I/O || 7. File I/O
8. Packages || 9. Objects || 10. Event Scheduling || 11. Datablocks || 12. Video / Texturing || 13. Special || 14. Resource Management
15. Scene || 16. Containers and Raycasts || 17. Editors || 18. Build || 19. Time || 20. GUIs || 21. Math