TorqueScript Reference
Functions
Meta-Scripting

Functions

String call (funcName, [args ...]?)
 
Boolean compile (fileName)
 
String compilePath (path)
 
void debug ()
 
void deleteVariables (wildCard)
 
String enumerateConsoleClasses ([baseClass]?)
 
String eval (script)
 
Boolean exec (fileName, [nocalls]?, [journalScript]?)
 
Boolean execPrefs (fileName, [nocalls]?, [journalScript]?)
 
String getAppleDeviceIPAddress ()
 
String getDSOPath (scriptFileName)
 
String getModNameFromPath (string path)
 
String getPrefsPath ([fileName]?)
 
String getVariable (string varName)
 
Boolean isFunction (string funcName)
 
Boolean isMethod (string namespace, string method)
 
void setScriptExecEcho (echo?)
 
void trace (enable)
 
 void (wildCard, [fileName]?, [append]?)
 

Detailed Description

Function Documentation

◆ call()

String call ( funcName  ,
[args ... ] ?   
)

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

Parameters
funcNameA 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

◆ compile()

Boolean compile ( fileName  )

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

Parameters
fileNameA 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

◆ compilePath()

String compilePath ( path  )

◆ debug()

void debug ( )

Use the debug function to cause the engine to issue a debug break and to break into an active debugger. For this to work, the engine must have been compiled with either TORQUE_DEBUG, or INTERNAL_RELEASE defined

Returns
No return value.

◆ deleteVariables()

void deleteVariables ( wildCard  )

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

Parameters
wildCardA string identifying what variable(s) to delete. All characters used to create a global are allowed and the special symbol *\, meaning 0 or more instances of any character.
Returns
No return value

◆ enumerateConsoleClasses()

String enumerateConsoleClasses ( [baseClass] ?  )

◆ eval()

String eval ( script  )

Use the eval function to execute any valid script statement. If you choose to eval a multi-line statement, be sure that there are no comments or comment blocks embedded in the script string.

Parameters
scriptA string containing a valid script statement. This may be a single line statement or multiple lines concatenated together with new-line characters.
Returns
Returns the result of executing the script statement.
See also
call

◆ exec()

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

Use the exec function to compile and execute a normal script, or a special journal script. If $Pref::ignoreDSOs is set to true, the system will use .cs before a .dso file if both are found.

Parameters
fileNameA string containing a path to the script to be compiled and executed.
nocallsA 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.
journalScriptA 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.
See also
compile

◆ execPrefs()

Boolean execPrefs ( fileName  ,
[nocalls] ?  ,
[journalScript] ?   
)

◆ getAppleDeviceIPAddress()

String getAppleDeviceIPAddress ( )

Gets the Apple hardware local IP on wifi. Should work on OS X and iOS

◆ getDSOPath()

String getDSOPath ( scriptFileName  )

Returns the DSO path of the given filename

Parameters
scriptFileNameA string contains the file to search for
Returns
Returns either the requested pathname as a string, or an empty string if not found.

◆ getModNameFromPath()

String getModNameFromPath ( string  path)

Attempts to extract a mod directory from path. Returns empty string on failure.

◆ getPrefsPath()

String getPrefsPath ( [fileName] ?  )

◆ getVariable()

String getVariable ( string  varName)

Grabs the relevant data for the variable represented by the given string

Parameters
varNameA String representing the variable to check
Returns
Returns a string containing component data for the requested variable or an empty string if not found.

◆ isFunction()

Boolean isFunction ( string  funcName)

Checks whether given name represents a current valid function.

Parameters
funcNameThe name of the function to check.
Returns
Returns either true if the string represents a valid function or false if not.

◆ isMethod()

Boolean isMethod ( string  namespace,
string  method 
)

Checks whether the given method name represents a valid method within the given namespace.

Parameters
namespaceA string representing the namespace in which the method should reside.
methodThe name of the method in question.
Returns
Returns a boolean value which is true if the given mathod name represents a valid method in the namespace and false otherwise.

◆ setScriptExecEcho()

void setScriptExecEcho ( echo )

Whether to echo script file execution or not.

◆ trace()

void trace ( enable  )

Use the trace function to enable (or disable) function call tracing. If enabled, tracing will print a message every time a function is entered, showing what arguments it received, and it will print a message every time a function is exited, showing the return value (or last value of last statement) for that function.

Parameters
enableA boolean value. If set to true, tracing is enabled, otherwise it is disabled.
Returns
No return value

◆ void()

void ( wildCard  ,
[fileName] ?  ,
[append] ?   
)

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.

Parameters
wildCardA string identifying what variable(s) to export. All characters used to create a global are allowed and the special symbol *\, meaning 0 or more instances of any character.
fileNameA string containing a path to a file in which to save the globals and their definitions.
appendA boolean value. If this value is true, the file will be appended to if it exists, otherwise it will be created/over-written.
Returns
No return value