torque_reference

Appendix A. The Torque Reference The following tables refer to the Torque Game Engine release version 1.3 engine build. Some notes about the functions:

Some functions are available for use on the client only. For the most part, this is very obvious. For example, any hardware-related functions are client-only. However, for other functions this may not be so obvious. These functions are marked "client-only."

Torque is not case-sensitive with respect to identifiers, like variables and function names. (Although TorqueScript keywords like if, function, while and so on are case-sensitive. See Table A.3 for a list TorqueScript keywords.) The Torque functions in this list all begin with lowercase letters, even though in many programming circles it is conventional for function identifiers to begin with capitals. The reference is written to conform to the Torque internal representation, but you can capitalize the functions if you need to to match your programming standards.

Note

TorqueScript is both a compiled and an interpreted language. Most of the functions in this reference can be used in real-time through the Torque console window by directly typing in the function with the appropriate parameters and correct syntax with proper usage, and all of them can be used script programs.

Because of this duality, the word function may be supplanted by the word command, depending on the usage context. They both mean the same thing—they both refer to TorqueScript executable statements that invoke a block of code defined elsewhere in script or in the Torque engine itself. However, when we write script programs, we use function to describe such a program statement. When we type in the statement directly using the console, we call it a command.

If you choose not to worry about the context, then feel free to call them all functions, or call them all commands—whatever twists your crank. However, take note that the keyword function has a specific meaning and usage, as described in Chapter 2.

So if you see code that looks like this:

function Fubar

{

echo("tarfu");

}

You can NOT substitute the word "command" for the word "function," since "command" is not a keyword. But you can still call Fubar a command when speaking or writing about it, and not be wrong.

TorqueScript Function Reference activateDirectInput Parameters: none Return: nothing Description: Activates direct input device polling Usage: activateDirectInput;

activateKeyboard Parameters: none Return: numeric 1 = success, 0 = fail. Description: Enables DirectInput polling of the keyboard Usage: %result = activateKeyboard;

activatePackage(name) Parameters: name String containing the name of the package Return: nothing Description: Tells Torque to start using the package specified by name Usage: activatePackage(Show);

addCardProfile(vendor, renderer, safeMode, lockArray, subImage, fogTexture, noEnvColor, clipHigh, deleteContext, texCompress, interiorLock, skipFirstFog, only16, noArraysAlpha, profile) Parameters: vendor Name of card vendor renderer Name of renderer safeMode true or false lockArray true or false subImage true or false fogTexture true or false noEnvColor true or false clipHigh true or false deleteContext true or false texCompress true or false interiorLock true or false skipFirstFog true or false only16 true or false noArraysAlpha true or false profile Name of profile Return: nothing Description: Creates a profile of features of a video card for later reference Usage: addCardProfile(%vendor, %renderer, true, true, true, true, true, false, false, true, true, false, false, false,"")

addMaterialMapping(material, sound, color) Parameters: material Name string to identify the material sound Name of sound profile to attach to material color Color specification to attach to material Return: nothing Description: Adds sound and dust color to specified material Usage: addMaterialMapping("sand", "sound:0", "color:0.3 0.3 0.5 0.4 0.0");

addOSCardProfile(vendor,renderer,allowOpenGL,allowD3D,preferOpenGL) Parameters: vendor Name of card vendor Renderer Name of renderer AllowOpenGL true or false allowD3D true or false preferOpenGL true or false Return: nothing Description: Stores certain aspects of a video card for later usage Usage: addOSCardProfile(%vendor,%renderer,true,true,true);

addTaggedString (string) Parameters: string Normal string to be added Return: numeric The tag Description: Adds a string to the tagged string list (NetStringTable) Usage: %tagname = AddTaggedString(%name);

aiAddPlayer(name, AIClass) Parameters: name AI character's name AIClass Character class or namespace Return: numeric New AIPlayer handle Description: Adds an AI Player to the game Usage: %handle=aiAddPlayer("Boss",RTSUnit);

aiConnect(id) Parameters: id ID reference number (0 to 20) of the AI bot Return: numeric New object handle Description: Creates a new uncontrolled AI connection. The AI is treated the same as a player. Usage: aiConnect(1);

alGetListener3f(ALenum) Parameters: ALenum The enum string. Choices: "AL_VELOCITY"

"AL_POSITION"

"AL_DIRECTION" Return: numeric Description: Queries the value of the ALenum Usage: %direction = alGetListener3f("AL_DIRECTION");

alGetListeneri(ALenum) Parameters: ALenum The enum string. Choices: "AL_CONE_INNER_ANGLE"

"AL_CONE_OUTER_ANGLE"

"AL_LOOPING"

"AL_STREAMING"

"AL_BUFFER" Return: numeric Description: Queries the value of the ALenum Usage: %looping = alGetListeneri("AL_LOOPING");

alGetString(ALenum) Parameters: string The enum string. Choices: "AL_VENDOR"

"AL_VERSION"

"AL_RENDERER"

"AL_EXTENSIONS" Return: string Description: Obtains the string specified Usage: %vendor = alGetString("AL_VENDOR");

alListener3f(ALenum, [ "x y z" ] | [ x,y,z ]) Parameters: ALenum The enum string. Choices: "AL_VELOCITY"

"AL_POSITION"

"AL_DIRECTION" "x y z" The string contains a tuple indicating where to place the enumed property in 3D world space. x,y,z (alternative) If "x y z" isn't used, then this is a tuple indicating where to place the audio object in 3D world space. Note: These are three numerics, not a string! Return: nothing Description: Sets the ALenum to value for the listener (the player, who "hears" a sound) Usage: alListener3f("AL_GAIN_LINEAR", $pref::Audio::masterVolume);

allowConnections(switch) Parameters: switch 1 (or true) = enable, 0 (or false) = disable. Return: nothing Description: Enables and disables connections to the game server Usage: allowConnections(true);

alxCreateSource( { profile, [x,y,z] } | { description, filename, [x,y,z] } ) Parameters: profile Descriptor string x,y,z If profile is used, this is a tuple indicating where to place the audio object. Note: These are three numerics, not a string! description (alternative) If profile isn't used, then this is an audio object description string. filename If description is used, then this string specifies the audio file to use for the sound. x,y,z If description is used, this is a tuple indicating where to place the audio object. Note: These are three numerics, not a string! Return: numeric Handle to audio object Description: Loads an audio source file into memory and initializes it for use Usage: $handle =alxCreateSource("Audio0","~/data/sounds/test.wav");

alxGetChannelVolume(channel) Parameters: channel Channel ID number Return: numeric Description: Queries the volume of channel Usage: %vol = alxGetChannelVolume(%channel);

alxGetListenerf(ALenum) Parameters: ALenum The enum string. Choices: "AL_GAIN"

"AL_GAIN_LINEAR" Return: numeric Description: Queries the value of the ALenum Usage: %gain = alxGetListenerf("AL_GAIN");

alxGetSource3f(handle, ALenum) Parameters: handle Handle to audio object ALenum The enum string. Choices: "AL_VELOCITY"

"AL_POSITION"

"AL_DIRECTION" Return: string "x y z" Description: Obtains the value of ALenum for the specified handle Usage: %pos = alxGetSource3f(%handle[%sender], "AL_POSITION");

alxGetSourcef(handle, ALenum) Parameters: handle Handle to audio object ALenum The enum string. Choices: "AL_PITCH"

"AL_REFERENCE_DISTANCE"

"AL_MAX_DISTANCE"

"AL_CONE_OUTER_GAIN"

"AL_GAIN"

"AL_GAIN_LINEAR" Return: numeric Description: Obtains the value of ALenum for the specified handle Usage: %gain = alxGetSourcef(%handle[%sender], "AL_GAIN");

alxGetSourcei(handle, ALenum) Parameters: handle Handle to audio object ALenum The enum string. Choices: "AL_CONE_INNER_ANGLE"

"AL_CONE_OUTER_ANGLE"

"AL_LOOPING"

"AL_STREAMING"

"AL_BUFFER" Return: numeric The pitch value Description: Obtains the value of ALenum for the specified handle Usage: %pitch = alxGetSourcei((%handle[%sender], "AL_LOOPING");

alxGetWaveLen(fileName) Parameters: string fileName Return: numeric length of file in milliseconds Description: Obtains the length in milliseconds of the .wav file specified by fileName Usage: %len = alxGetWaveLen (%pathToWaveFile);

alxIsPlaying(handle) Parameters: handle Handle to audio object Return: numeric 1 = true, 0 = false Description: Queries if a handle is currently playing Usage: %isPlaying = alxIsPlaying(%handle);

alxListenerf(ALenum,value) Parameters: ALenum The enum string. Choices: "AL_GAIN"

"AL_GAIN_LINEAR" value Numeric gain value Return: nothing Description: Sets the ALenum to value for the Listener (the player, who "hears" a sound) Usage: alxListenerf("AL_GAIN_LINEAR", %vol );

alxPlay( [ handle ] | [ profile [, x,y,z ] ] ) Parameters: handle Handle to audio object profile (alternative) Descriptor string x,y,z If profile is used, this is a tuple indicating where to place the audio object. Note: These are three numerics, not a string! (optional) Return: numeric Returns object handle if profile is used. Description: Begins audio playback with audio object specified by handle. Alternatively, if profile is used, this function creates an object, begins playback at optional x,y,z coordinates and then returns a handle to the created object. Usage: %handle0 = alxCreateSource("Audio0", "~/data/sounds/test.wav"); alxPlay(%handle0);

%handle1 = alxPlay("Audio1", "100, 100, 10");

alxSetChannelVolume(channel, volume) Parameters: channel Channel ID number volume Volume value Return: numeric 1 = success, 0 = fail Description: Sets the channel to volume Usage: %result = alxSetChannelVolume(%channel, %volume);

alxSource3f(handle,ALenum, [ "x y z" ] | [ x,y,z ] ) Parameters: handle Handle to audio object ALenum The enum string. Choices: "AL_VELOCITY"

"AL_POSITION"

"AL_DIRECTION" "x y z" String containing a tuple indicating where to place the enumed property in 3D world space x,y,z (alternative) If "x y z" isn't used, then this is a tuple indicating where to place the audio object in 3D world space. Note: These are three numerics, not a string! Return: nothing Description: Sets ALenum for the specified handle to 3D Usage: alxSource3f(%handle[%sender], "AL_POSITION", "100 100 20");

alxSourcef(handle, ALenum, value) Parameters: handle Handle to audio object ALenum The enum string. Choices: "AL_PITCH"

"AL_REFERENCE_DISTANCE"

"AL_MAX_DISTANCE"

"AL_CONE_OUTER_GAIN"

"AL_GAIN"

"AL_GAIN_LINEAR" value Numeric (floating point) value to set ALenum to Return: nothing Description: Sets ALenum for the specified handle to the floating-point value Usage: alxSourcef(%handle[%sender], "AL_GAIN", %gain);

alxSourcei(handle, ALenum, value) Parameters: handle Handle to audio object ALenum The enum string. Choices: "AL_CONE_INNER_ANGLE"

"AL_CONE_OUTER_ANGLE"

"AL_LOOPING"

"AL_STREAMING"

"AL_BUFFER" value Numeric value to set ALenum to. Return: nothing Description: Sets ALenum for the specified handle to the floating-point value Usage: alxSourcei(%handle[%sender], "AL_LOOPING", true);

alxStop(handle) Parameters: handle Handle to audio object Return: nothing Description: Stops the playback from handle Usage: alxStop(%handle[%sender]);

alxStopAll Parameters: none Return: nothing Description: Stops the playback on all registered channels Usage: alxStopAll;

backtrace Parameters: none Return: nothing Description: Enables echo of script call stack to console Usage: backtrace;

buildTaggedString(string, format) Parameters: string Normal string to be added format Format specifying string Return: string Description: Builds and adds a tagged string using string with specified format. Usage: %tagstring = buildTaggedString(%name, %format);

calcExplosionCoverage(location, handle, mask) Parameters: location Where the target object is  handle Target object mask Object type mask of objects that may block the explosion Return: numeric 1 = affected, 0 = unaffected Description: Determines if an object at a location was affected by an explosion. Listed object types will be taken into consideration in the calculation if they would block the explosion force. Usage: %coverage = calcExplosionCoverage(%location, %targetObject, $TypeMasks::InteriorObjectType | $TypeMasks::TerrainObjectType


 * $TypeMasks::VehicleObjectType);

call(function [,args ...]) Parameters: function String containing name of function args Zero or more arguments as needed by function Return: string Function's return value embedded in a string Description: Executes the function with the name function with supplied arguments, args Usage: %result = call(%func, %arg1, %arg2);

cancel(id) Parameters: id ID number of supposed event Return: nothing Description: Cancels the event specified by id Usage: cancel($eventid);

cancelServerQuery Parameters: none Return: nothing Description: Cancels the current query and drops anything outstanding in the ping list Usage: cancelServerQuery;

clearServerPaths Parameters: none Return: none Description: Clears all stored paths held by the path manager and releases the memory used Usage: clearServerPaths;

clearTextureHolds Parameters: none Return: numeric Amount of memory released Description: Releases any textures not being used, and frees the memory Usage: %clearedMem=clearTextureHolds;

cls Parameters: none Return: none Description: Clears the console screen Usage: cls;

collapseEscape(text) Parameters: text String Return: string The resultant string Description: Removes escaped characters in text. For example, \\n becomes \n. Usage: %coltext = collapseEscape(%text);

commandToClient(client, function [,arg1,...argn]) Parameters: client Handle of target client function Function on the server to be executed arg1,...argn Arguments for the function Return: nothing Description: Tells client to execute the command or function specified by function and passes it the arguments. On the client, the function is declared in the following format: function clientCmdfunction(arg1,...argn) { ... }

The identifier fragment clientCmd is prepended to the function name. Usage: commandToClient(%client, 'SyncClock', %time);

commandToServer(function [,arg1,...argn]) Parameters: function Function on the server to be executed arg1,...argn Arguments for the function Return: nothing Description: Tells the server to execute the command or function specified by function, and passes it the arguments. On the server, the function is declared in the following format:

function serverCmdfunction(%client, arg1,...argn) { ... }

The identifier serverCmd is prepended to the function name. The first parameter is always the handle of the client that sent the command, and the actual command arguments follow. Usage: commandToServer('ToggleCamera');

compile(fileName) Parameters: filename String containing filename Return: numeric 1 = success, 0 = fail Description: Compiles the source script file filename Usage: %result = compile("/common/default.cs");

containerBoxEmpty(mask, loc, rad [,yrad, zrad]) Parameters: mask Object type mask loc Coordinate tuple rad Radius distance (or X-axis distance) yrad Optional distance in Y-axis zrad Optional distance in Z-axis Return: numeric Description: Returns true if any objects of given types exist in a sphere of the specified extent rad and false otherwise. If yrad is specified, then rad is the X-axis extent, and yrad is the Y-axis extent. If zrad is specified, it becomes the Z-axis extent. Usage: %isAny = containerBoxEmpty(ItemObjectType,"10.0 10.0 100.0", 100);

containerFindFirst(type, point, x, y, z) Parameters: type The type mask of objects to find point Location of container x, y,z Numeric bounds of container specified. Not a string. Return: numeric Handle of object found Description: Finds objects of type within the box specified with x,y,z at the given point point. Returns the handle of the first object found. Usage: %objectHandle = containerFindFirst(type, point, x, y, z);

containerFindNext Parameters: none Return: numeric Handle of object found Description: Finds the next object in the container specified immediately preceding call to containerFindFirst, and gets its handle. Usage: %objectHandle = containerFindNext;

containerRayCast (start, end, mask, [exclude]) Parameters: start Starting coordinate tuple end Ending coordinate tuple mask Object type mask exclude List of handles Return: string Hit list Description: Finds a list of objects of type mask between the two cords supplied. A list of object handles can be included in the exempt parameter that will not be returned in the hit list. Usage: %tgt = containerRayCast (%cameraPoint, %rangeEnd, ItemObjectType);

containerSearchCurrDist Parameters: none Return: numeric Description: Gets the current container search distance Usage: %dist = containerSearchCurrDist;

containerSearchCurrRadiusDist Parameters: none Return: numeric Description: Gets the current container search radius distance Usage: %rad = containerSearchCurrRadiusDist;

containerSearchNext Parameters: none Return: numeric Description: Gets the next object in a container search Usage: %nc = containerSearchNext;

createCanvas(title) Parameters: title String containing title of the window Return: numeric 1 = success, 0 = fail Description: Creates a graphics "canvas" in a window Usage: %result = createCanvas("My Game");

dbgSetParameters (port, pw) Parameters: port Connection port pw Password Return: nothing Description: Initializes telnet debug connection request parameters Usage: dbgSetParameters(1130, "games");

deactivateDirectInput Parameters: none Return: nothing Description: Disables DirectInput device polling (mouse, keyboard, joystick) Usage: deactivateDirectInput;

deactivateKeyboard Parameters: none Return: nothing Description: Disables DirectInput polling of the keyboard Usage: deactivateKeyboard;

deactivatePackage(name) Parameters: name String containing the name of the package Return: nothing Description: Tells Torque to stop using the package specified by name Usage: deactivatePackage(Show);

debug Parameters: none Return: nothing Description: Enables debug mode Usage: debug;

debug_debugbreak Parameters: none Return: nothing Description: Windows: Displays a crash dialog box Linux: Causes a segfault Usage: debug_debugbreak;

debug_testx86unixmutex Parameters: none Return: nothing Description: Linux only: Check if OS can create a mutex Usage: debug_testx86unixmutex;

decreaseFSAA Parameters: none Return: nothing Description: Decrements FSAA level by 1 Usage: decreaseFSAA

deleteDataBlocks Parameters: none Return: nothing Description: Unloads and removes all registered data blocks from the game Usage: deleteDataBlocks;

deleteVariables(wildcard) Parameters: wildcard Match string to specify variables Return: nothing Description: Deletes global variables specified by wildcard. The wildcard string supports "*" to match any number of any characters and "?" to match any single character. Usage: deleteVariables("*");

detag(tstring) Parameters: tstring Tagged string Return: string String value for the tagged string Description: Detags a tagged string Usage: %name = detag(%test.name);

disableJoystick Parameters: none Return: nothing Description: Disables DirectInput polling of the joystick device Usage: disableJoystick;

disableLocking Parameters: none Return: nothing Description: Disables UNIX/Linux lock mechanism Usage: disableLocking;

disableMouse Parameters: none Return: nothing Description: Disables DirectInput polling of the mouse device Usage: disableMouse;

dnetSetLogging(switch) Parameters: switch 1 (or true) = enable, 0 (or false ) = disable Return: nothing Description: Enables network packet logging to the console Usage: dnetSetLogging(1);

dumpConsoleClasses Parameters: none Return: nothing Description: Dumps all registered console classes to the console Usage: dumpConsoleClasses;

dumpMemSnapshot(filename) Parameters: filename String containing filename Return: nothing Description: Dumps memory statistics to the file Usage: dumpMemSnapshot("dump.txt");

dumpNetStringTable Parameters: none Return: nothing Description: Dumps the NetStringTable stats to the console Usage: dumpNetStringTable;

dumpResourceStats; Parameters: none Return: nothing Description: Dumps texture information to the console in the following format: path, resource, lockCount Usage: dumpResourceStats;

dumpTextureStats Parameters: none Return: nothing Description: Dumps texture information to the console in the following format: type, refCount, holding (yes or no), textureSpace, texFileName Usage: dumpTextureStats;

echo(text) Parameters: text String Return: nothing Description: Prints text to the console with the standard font. Text can be formatted according to the string rules. Usage: echo("Hello World");

echoInputState Parameters: none Return: nothing Description: Displays the current state of DirectInput (mouse, keyboard, and joystick) Usage: echoInputState;

enableJoystick Parameters: none Return: nothing Description: Enables DirectInput polling of the joystick device Usage: enableJoystick;

enableLocking Parameters: none Return: nothing Description: Enables UNIX/Linux lock mechanism Usage: enableLocking;

enableMouse Parameters: none Return: numeric 1 = success, 0 = fail Description: Enables DirectInput polling of the mouse device Usage: %result = enableMouse;

enableWinConsole(switch) Parameters: switch 1 enables, 0 disables Return: nothing Description: Displays the console window Usage: enableWinConsole(true);

error(text) Parameters: text String Return: nothing Description: Prints text to the console with red font. Text can be formatted according to the string rules. Usage: error("I'm sorry, Dave, I'm afraid I can't do that.");

eval(string) Parameters: string String containing script code Return: string Description: Executes functions, assigns variables, and loads packages and data blocks contained within the string parameter. Usage: %result = eval(%MissionInfoObject );

exec(fileName [, nocalls [,journalScript] ]) Parameters: filename String containing filename nocalls When set to true, prevents functions from being called journalScript When set to true, indicates that filename is a journal script Return: string Description: Compiles, executes functions, assigns variables, and loads packages and data blocks read from contents of the file filename. If nocalls is set to true, functions are not executed, but the other operations still take place. Usage: %result = exec("/common/default.cs");

expandEscape(text) Parameters: text String Return: string The resultant string Description: Escapes all of the escape characters in text. For example, \n becomes \\n. In this case the \n would be printed to the console instead of the new line it would otherwise cause. Usage: %extext = expandEscape(%text);

expandFilename(filename) Parameters: filename String containing filename Return: string Description: Obtains the actual OS-specific absolute path of filename Usage: %fullmissionpath = expandFilename("~/data/missions/test.mis");

export(searchString [, fileName [,append]]) Parameters: search Prefix of variables to search for filename String containing filename append Indicates whether to append to file or overwrite Return: nothing Description: Saves the values of variables starting with search to the filenamed filename. When append is set to true, the file is appended; when set to false, the file is overwritten. The search string supports "*" to match any number of any characters and "?" to match any single character. Usage: %result = export("$Pref::Game::*", "./game/prefs.cs", False);

fileBase(filename) Parameters: filename String containing full filename Return: string String containing the base name Description: Gets the base name of the file specified by filename Usage: %base = fileBase("/common/server/script.cs");

fileExt(filename) Parameters: filename String containing full filename Return: string String containing extension Description: Gets the extension of the file specified by filename Usage: %name = fileExt("script.cs");

fileName(filename) Parameters: filename String containing full filename Return: string String containing the name Description: Gets the name of the file specified by filename Usage: %name = fileName("scripts.cs");

filePath(filename) Parameters: filename String containing full filename Return: string String containing the path Description: Gets the path of the file specified by filename Usage: %path = filePath("/common/server/script.cs");

findFirstFile (pattern) Parameters: pattern String pattern Return: string The file's name Description: Finds the name of the first file in the TorqueScript filename buffer matching the given pattern. Supports "*" to match any number of any characters and "?" to match any single character. Usage: %result = findFirstFile("/common/*.cs");

findNextFile (pattern) Parameters: pattern String pattern Return: string The file's name Description: Finds the name of the next file in the TorqueScript filename buffer matching the search by the call immediately preceding findFirstFile. Supports "*" to match any number of any characters and "?" to match any single character. Usage: %result = findNextFile("/common/*.cs");

firstWord(text) Parameters: text String with space-delimited words Return: string The resultant string Description: Gets the first word-string within text Usage: %tgt = firstWord(%text);

flushTextureCache Parameters: none Return: nothing Description: Deletes cached textures from memory. Usage: flushTextureCache;

freeMemoryDump Parameters: none Return: nothing Description: Prints free memory statistics Usage: freeMemoryDump;

getBoxCenter(box) Parameters: box String containing two 3D tuples defining the box Return: string Description: Computes the center of a box Usage: %c = getBoxCenter("10,10,10,50,50,50");

getBuildString Parameters: none Return: string Description: Obtains the BUILD type (Release or Debug) of the current build Usage: %bs = getBuildString;

getClipboard Parameters: none Return: string clipboard contents Description: Extracts the text contained in the current OS clipboard (this is the clipboard that the OS uses for copy/paste operations) Usage: %text = getClipboard ;

getCompileTimeString Parameters: none Return: string Description: Obtains the compile time and date of the current build Usage: %ct = getCompileTimeString;

getControlObjectAltitude Parameters: none Return: numeric Description: Client-only. Obtains the altitude of the player object. Usage: %altitude = getControlObjectAltitude;

getControlObjectSpeed Parameters: none Return: numeric Description: Client-only. Obtains the speed of the player object. Usage: %speed = getControlObjectSpeed;

getDesktopResolution Parameters: none Return: string Description: Reports the current desktop resolution Usage: %res = getDesktopResolution:

getDisplayDeviceList Parameters: none Return: string Description: Obtains the device name for each display device Usage: %name = getDisplayDeviceList;

getField(text, index) Parameters: text String with field-delimited words index Field-based offset into the text string Return: string Contains the found field-string Description: Gets the field-string at index within text. In the usage example that follows, if %text equaled "Of Mice and Men", then %word would be set to "and" when the function returned. Usage: %field = getField(%text, 0);

getFieldCount (text) Parameters: text String with field-delimited words Return: numeric Description: Gets the number of field-strings within text Usage: %count = getFieldCount( %text );

getFields(text, first [, last]) Parameters: text String with space-delimited fields first Field-based offset into the text string specifying the first field to extract last Field-based offset into the text string specifying the last field to extract Return: string Contains the found fields Description: Gets one or more field-strings at index within text. If count is specified, gets count number of field-strings. Usage: %position = getFields(%obj.getTransform, 0, 2);

getFileCount (pattern) Parameters: pattern String pattern Return: numeric Description: Gets the number of files in the TorqueScript filename buffer that match pattern Usage: %count = getFileCount("/common/server/*.cs");

getFileCRC(filename) Parameters: filename String containing full filename Return: numeric The Cyclic Redundancy Check(CRC) value Description: Gets the CRC value of the file specified by filename Usage: %crc = getFileCRC("/common/server/script.cs");

getJoystickAxes(instance) Parameters: instance The joystick object Return: string Description: Obtains the current axes of the joystick pointed to by instance Usage: %joyAxes = getJoystickAxes( 3 );

getMaxFrameAllocation Parameters: none Return: numeric Description: Gets the Max Frame Allocation unit Usage: %maxFrameAlloc = getMaxFrameAllocation;

getModPaths Parameters: none Return: string Description: Gets the current Mod path Usage: $mp = getModPaths;

getRandom([min,max) Parameters: max High limit (optional) min Low limit (optional) Return: numeric Ranged from 0 to 1, exclusive, if no parameters given, otherwise, see description Description: Computes a pseudo-random number. If min is not included, then 0 is the minimum. If max is not included, then 4,294,967,295 (highest 32-bit number minus 1) is the maximum. Usage: %random = getRandom(1,99);

getRandomSeed Parameters: none Return: numeric Description: Obtains the current random seed Usage: %seed = getRandomSeed;

getRealTime Parameters: none Return: numeric Description: Gets the real time (in milliseconds) since this computer started Usage: %rt = getRealTime;

getRecord(text, index) Parameters: text String with new line-delimited records index Record-based offset into the text string Return: string Contains the found record-string Description: Gets the record-string at index within text. In the usage example that follows, if %text equaled "Of Mice and Men\nGrapes of Wrath\nCannery Row", then %record would be set to "Grapes of Wrath" when the function returned. Usage: %record = getRecord(%text, 1);

getRecordCount(text) Parameters: text String with new line-delimited records Return: numeric Description: Get the number of record-strings within text Usage: %count = getRecordCount(%text );

getRecords(text, first [, last]) Parameters: text String with new line-delimited records first Record-based offset into the text string specifying the first record to extract last Record-based offset into the text string specifying the last record to extract Return: string Contains the found records Description: Gets one or more record-strings at index within text. If count is specified, gets count number of record-strings. Usage: %books = getRecords(%obj.getTransform, 0, 2);

getRes Parameters: none Return: string "w h bpp" w: width h: height bpp: bits per pixel Description: Gets the width, height, and bit depth of the screen Usage: %res = getRes:

getResolutionList(devicename) Parameters: devicename Name of the device to query Return: string Description: Obtains all available resolutions for the specified device Usage: %rl = getResolutionList(%device);

getServerCount Parameters: none Return: numeric Description: Gets the number of available servers from the master server Usage: %sc = getServerCount;

getSimTime Parameters: none Return: numeric Description: Gets the current game time Usage: %st = GetSimTime;

getSubStr(str, loc, count) Parameters: str String to be processed loc Offset into str to get start of substring from count Number of characters to get Return: string The processed resultant string Description: Gets the substring of string that begins at loc, continuing for count characters or to the end of the string, whichever comes first Usage: %sub = getSubStr(%text, 5, 99);

getTag(tstring) Parameters: tstring Tagged string Return: string Description: Gets the tag for the tagged string tstring Usage: %tag = getTag(%variable);

getTaggedString(tag) Parameters: tag Numeric tag of string to be removed Return: string Description: Gets the string associated with tag Usage: %name = getTaggedString( %tagname );

getTerrainHeight(pos) Parameters: pos 2D coordinate Return: numeric Description: Gets the terrain height at the specified position Usage: %height = getTerrainHeight(%pos);

getVersionNumber Parameters: none Return: numeric Description: Obtains the hard-coded engine version number of the current build Usage: %vn = getVersionNumber;

getVersionString Parameters: none Return: string Description: Obtains the hard-coded engine version string of the current build Usage: %vs = getVersionString ;

getVideoDriverInfo Parameters: none Return: string Description: Gets device driver information Usage: %info = getVideoDriverInfo;

getWord(text, index) Parameters: text String with space-delimited words index Word-based offset into the text string Return: string Contains the found word-string Description: Gets the word-string at index within text. In the usage example that follows, if %text equaled "Of Mice and Men", then %word would be set to "and" when the function returned. Usage: %word = getWord(%text, 2);

getWordCount(text) Parameters: text String with space-delimited words Return: numeric Description: Gets the number of word-strings within text Usage: %count = getWordCount( %text );

getWords(text, first [, last]) Parameters: text String with space-delimited words first Word-based offset into the text string specifying the first word to extract last Word-based offset into the text string specifying the last word to extract Return: string Contains the found words Description: Gets one or more word-strings at index within text. If count is specified, gets count number of word-strings. Usage: %position = getWords(%obj.getTransform, 0, 2);

GLEnableLogging(switch) Parameters: switch 1 enables, 0 disables Return: nothing Description: Enables OpenGL logging to gl_log.txt Usage: GLEnableLogging(true);

GLEnableMetrics(switch) Parameters: switch 1 enables, 0 disables Return: nothing Description: Tracks metrics data for OpenGL features Usage: GLEnableMetrics(1);

GLEnableOutline(switch) Parameters: switch 1 enables, 0 disables Return: nothing Description: Enables OpenGL wire-frame mode Usage: GLEnableOutline(true);

gotoWebPage( address ) Parameters: address URL of web page Return: nothing Description: Opens default browser with specified address Usage: gotoWebPage("http://www.tubettiworld.com/");

increaseFSAA Parameters: none Return: nothing Description: Increments FSAA level by 1 Usage: increaseFSAA

initContainerRadiusSearch (loc, radius, mask) Parameters: loc 3D coordinate radius To be searched mask Mask of object type to look for Return: nothing Description: Searches for objects of type mask within a radius around the location Usage: initContainerRadiusSearch("0 450 76", %somerad, DebrisObjectType);

inputLog(filename) Parameters: filename String containing filename Return: nothing Description: Windows Only: Enables or disables logging of DirectInput events to log file specified by string. Usage: inputLog(DI.log);

isDemoRecording Parameters: none Return: numeric 1 (or true) = enable, 0 (or false) = disable Description: Queries if a demo is currently being recorded Usage: %state = isDemoRecording;

isDeviceFullScreenOnly(devicename) Parameters: devicename Name of device to query Return: numeric 1 = yes, 0 = no Description: Queries if device is capable of full screen only Usage: isDeviceFullScreenOnly(%devicename);

isEventPending(%id) Parameters: id ID number to check Return: numeric 1 = true, 0 = false Description: Queries if an event is pending with an ID number of id Usage: %status =isEventPending($eventid);

isFile(filename) Parameters: filename String containing full filename Return: numeric 1 = true, 0 = false Description: Queries if the file exists in the TorqueScript filename buffer Usage: %result = isFile("/common/server/script.cs");

isFullScreen Parameters: none Return: numeric 1 = yes, 0 = no Description: Queries whether screen mode is set to full screen Usage: %result = isFullScreen;

isJoystickDetected Parameters: none Return: numeric 1 = true, 0 = false Description: Determines if a joystick is present Usage: %jd = isJoystickDetected;

isKoreanBuild Parameters: none Return: string Description: Korean registry key checker Usage: %kb = isKoreanBuild;

isObject(handle) Parameters: handle Handle of supposed object Return: numeric 1 = true, 0 = false Description: Queries if handle is an object Usage: %status = isObject(%chopper);

isPackage(name) Parameters: name String containing the name of the package Return: numeric 1 = true, 0 = false Description: Queries if name is a registered package Usage: %status = isPackage(Show);

isPointInside(point) Parameters: point "x y" Return: numeric 1 = true, 0 = false Description: Queries if point is coincident with the interior of any object Usage: %status = isPointInside("123 345 25");

isWriteableFileName(filename) Parameters: filename String containing full filename Return: numeric 1 = true, 0 = false Description: Queries if file specified by filename is writeable Usage: %result = isWriteableFileName("/common/server/script.cs");

lightScene(completion) Parameters: completion Completion callback Return: numeric Function handle Description: Lights the current mission using the callback function pointed to by completion when mission lighting is finished Usage: %result = lightScene("CompletionCallback")

lockMouse(switch) Parameters: switch 1 (or true) = lock, 0 (or false) = unlock Return: nothing Description: Toggles the mouse state Usage: lockMouse(true);

ltrim(str) Parameters: str String to be processed Return: string The processed resultant string Description: Strips any white space from str from the left side (before any other characters) of str. White space is defined as space, carriage returns, or new line characters. Usage: %tidystring = ltrim(%yuckystring);

mAbs(x) Parameters: x Operand. Can be an integer or a floating point. Return: numeric Description: Computes the absolute value of x Usage: %val = mAbs(76.3);

mAcos(x) Parameters: x Radians. Can be an integer or a floating point. Return: numeric Description: Computes the arc cosine Usage: %val = mAcos(2.0);

makeTestTerrain(filename) Parameters: filename String containing filename Return: nothing Description: Makes a test terrain file Usage: makeTestTerrain("testfile");

mAsin(x) Parameters: x Radian. Can be an integer or a floating point. Return: numeric Description: Computes the arc sine Usage: %val = mAsin(1.5);

mAtan(x,y) Parameters: x Radian. Can be an integer or a floating point. y Radians. Can be an integer or a floating point. Return: numeric Description: Computes the arc tangent Usage: %val = mAtan(-1.667,2);

mathInit(mode) Parameters: mode The string specifier. Choices: "DETECT"

"C"

"FPU"

"MMX"

"3DNOW"

"SSE" Return: nothing Description: Enables math extensions based on CPU type Usage: mathInit("DETECT");

matrixCreate(vector, angledvector) Parameters: vector "x y z"  angledvector "x y z angle" Return: string Description: Generates a matrix from the specified values Usage: %mtx = matrixCreate("10 10 30", "30 40 50 10");

matrixCreateFromEuler (valstring) Parameters: valstring "x y z" Return: string Description: Generates a matrix from given arguments Usage: %val = matrixCreateFromEuler("5.5 90 200");

matrixMulPoint(matrix, point) Parameters: matrix point Return: string Description: Multiplies a matrix by a point Usage: %mtx = matrixMulPoint(%matrix,%point);

matrixMultiply(matrixA, matrixB) Parameters: matrixA matrixB Return: string Description: Multiplies two matrices Usage: %mtx = matrixMultiply(matrix1,matrix2);

matrixMulVector(matrix, vector) Parameters: matrix vector Return: string Description: Multiplies a matrix by a vector Usage: %mtx = matrixMulVector(matrix,vector);

matrixReloaded Parameters: none Return: none Description: Hah! Got ya! No such function. Yet. Usage: there isn't any :-)

mCeil(x) Parameters: x Operand. Can be an integer or a floating point. Return: numeric Description: Finds the smallest integral value greater than or equal to the operand. Usage: %val = mCeil(%dialogHeight / %textHeight);

mCos(x) Parameters: x Radian. Can be an integer or a floating point. Return: numeric Description: Computes the cosine Usage: %val = mCos(69);

mDegToRad(degrees) Parameters: degrees Degrees to be converted. Can be an integer or a floating point. Return: numeric Description: Converts degrees to radians Usage: %rads = mDegToRad(90);

mFloatLength(x, len) Parameters: x Operand. Can be an integer or a floating point. len Number of decimal places Return: numeric Description: Returns x as a floating-point value with len decimal places Usage: %mypi = mFloatLength((21/7),8);

mFloor(x) Parameters: x Operand. Can be an integer or a floating point. Return: numeric Description: Finds the largest integral value less than or equal to the operand Usage: %val = mFloor(%dialogHeight / %textHeight);

mLog(x) Parameters: x Radian. Can be an integer or a floating point. Return: numeric Description: Computes the natural logarithm Usage: %val = mLog(7654.98);

mPow(x,y) Parameters: x Base. Can be an integer or a floating point. y Exponent. Can be an integer or a floating point. Return: numeric Description: Computes x raised to the power of y Usage: %val = mPow(2,4);

mRadToDeg(radians) Parameters: radians Radians to be converted. Can be integers or floating points. Return: numeric Description: Converts radians to degrees Usage: %degs = mRadToDeg(1);

msg(handle,message) Parameters: handle Handle of object to receive message message String containing message Return: nothing Description: Sends message to the object specified by handle Usage: msg(%objhandle, %msg);

mSin(x) Parameters: x Radian. Can be an integer or a floating point. Return: numeric Description: Computes the sine Usage: %val = mSin(65);

mSolveCubic(a,b,c,d) Parameters: a,b,c,d Operands. Can be integers or floating points. Return: string Description: Computes a cubic solution for x. ax^3 + bx^2 + cx + d = 0 Usage: %val = mSolveCubic(a,b,c,d);

mSolveQuadratic(a,b,c) Parameters: a,b,c Operands. Can be integers or floating points. Return: string Description: Computes a quadratic solution for x. ax^2 + bx + c = 0 Usage: %val = mSolveQuadratic(a,b,c);

mSolveQuartic(a,b,c,d,e) Parameters: a,b,c,d,e Operands. Can be integers or floating points. Return: string Description: Computes a quartic solution for x. ax^4 + bx^3 + cx^2 + dx + e = 0 Usage: %val = mSolveQuartic(a,b,c,d,e);

mSqrt(x) Parameters: x Operand. Can be an integer or a floating point. Return: numeric Description: Computes the square root of x Usage: %val = mSqrt(81);

mTan(x) Parameters: x Radian. Can be an integer or a floating point. Return: numeric Description: Computes the tangent Usage: %val = mTan(45.0);

nameToID(name) Parameters: name String containing the name of the object Return: nothing Description: Gets the ID number of the named object Usage: nameToID(%chopper);

nextResolution Parameters: none Return: numeric 1 = success, 0 = fail Description: Increases next highest resolution Usage: %result = nextResolution ;

nextToken (str,token,delim) Parameters: str Initializes tokenizer when set to a valid string variable. Uses an empty string ( "" ) to specify follow-up operation on the same string. token Reference handle to the variable that will receive the found token. Note: When passing a variable by reference to a function, such as with this parameter, you do not prefix the variable name with % or $. delim Specifies the character that delimits the tokens Return: string Balance of the string after the found token Description: Sets token to the next substring in str delimited by delim. The initial call to this function specifies str, subsequent calls to this function that operate on the same string must pass the empty string ( "" ). Usage: %str = nextToken("one,two,three", number, ",");

openALInitDriver Parameters: none Return: numeric Description: Initializes the sound driver Usage: openALInitDriver;

openALShutdownDriver Parameters: none Return: nothing Description: Disables the sound driver Usage: openALShutdownDriver;

panoramaScreenShot(filename) Parameters: filename String containing filename Return: nothing Description: Captures the panoramic screen view and saves it to the file specified by filename. The engine will take the panoroma shot as a sequence of three screen captures, looking left, center, then right. Usage: panoramaScreenShot("myPanorama");

pathOnMissionLoadDone Parameters: none Return: nothing Description: Sets the Mod path that will be active when a mission is finished loading Usage: pathOnMissionLoadDone("missE/mission");

permDisableMouse Parameters: none Return: nothing Description: Permanently disables DirectInput polling of the mouse device Usage: permDisableMouse;

playDemo(filename) Parameters: filename String containing filename Return: nothing Description: Plays back a demo saved in filename Usage: playDemo(MyNiftyDemo);

playJournal(name,[break]) Parameters: name String containing filename of journal break If true, then stops playback after each event Return: nothing Description: Plays back saved journal specified by name Usage: playJournal("myjrnl.jnl");

png2jpg(filename,quality) Parameters: filename String containing filename of PNG file to convert quality Conversion quality, numeric range 0 to 100 Return: numeric -1 = failure, 0 = success Description: Converts the PNG formatted file specified by filename to JPG format and writes resulting image file to disk with same name and path as filename but with JPG extension instead of PNG. Usage: png2jpg("image1.png", 100);

prevResolution Parameters: none Return: numeric 1 = success, 0 = fail Description: Decreases next highest resolution Usage: %result = prevResolution;

profilerDump Parameters: none Return: nothing Description: Dumps NetStringTable statistics to the console Usage: profilerDump;

profilerDumpToFile(filename) Parameters: filename String containing filename Return: nothing Description: Dumps NetStringTable statistics to the file specified by filename Usage: profilerDumpToFile(dump.txt);

profilerEnable(switch) Parameters: switch 1 enables, 0 disables Return: nothing Description: Enables or disables profiling Usage: profilerEnable(false);

profilerMarkerEnable(markerName, switch) Parameters: markerName Name of profile marker switch 1 enables, 0 disables Return: nothing Description: Enables or disables profiling for markerName Usage: profilerMarkerEnable(mark,true);

profilerReset Parameters: none Return: nothing Description: Resets the profiler, clearing all of its data Usage: profilerReset ;

purgeResources Parameters: none Return: nothing Description: Purges all resources used by the game through the resource manager Usage: purgeResources;

queryLANServers (port, flags, gametype, missiontype, minplayers, maxplayers, maxbots, regionmask, maxping, filterflags, mincpu) Parameters: port Host server port flags The query flags. Choices: 0x00 = online query

0x01 = offline query

0x02 = no string compression gametype Game type string missiontype Mission type string minplayers Minimum number of players for viable game maxplayers Maximum allowable players maxbots Maximum allowable connected AI bots regionmask Numeric discriminating mask maxping Maximum ping for connecting clients; 0 means no maximum. mincpu Minimum specified CPU capability filterflags Server filters. Choices: 0x00 = dedicated

0x01 = not password protected

0x02 = Linux

0x80 = current version Return: nothing Description: Queries all computers found in the LAN, examining the port specified with port. The responses are accessible from the ServerList array. Usage: queryLANServers(  28000, 0, $Client::GameTypeQuery, Client::MissionTypeQuery,   0, 100, 0, 2, 0, 100, 0);

queryMasterServer (port, flags, gametype, missiontype, minplayers, maxplayers, maxbots, regionmask, maxping, filterflags, mincpu) Parameters: flags The query flags. Choices: 0x00 = online query

0x01 = offline query

0x02 = no string compression gametype Game type string missiontype Mission type string minplayers Minimum number of players for viable game maxplayers Maximum allowable players maxbots Maximum allowable connected AI bots regionmask Numeric discriminating mask maxping Maximum ping for connecting clients; 0 means no maximum. mincpu Minimum specified CPU capability filterflags Server filters. Choices: 0x00 = dedicated

0x01 = not password protected

0x02 = Linux

0x80 = current version Return: nothing Description: Queries a master server looking for specified information. The responses are accessible from the ServerList array. Note: buddycount and buddylist are obsolete arguments and no longer included or used. Usage: queryMasterServer(  28000, 0, $Client::GameTypeQuery, Client:MissionTypeQuery,   0, 100, 0, 2, 0, 100, 0);

querySingleServer(address, flags) Parameters: address IP address of server flags The query flags. Choices: 0x00 = online query

0x01 = offline query

0x02 = no string compression Return: nothing Description: Queries a single server looking for a game being served. The responses are accessible from the ServerList array. Usage: querySingleServer ("192.168.100.1",0);

quit Parameters: none Return: nothing Description: Quits the game Usage: quit;

redbookClose Parameters: none Return: numeric 1 = success, 0 = fail Description: Closes the currently open redbook (CD) device Usage: %result = redbookClose;

redbookGetDeviceCount Parameters: none Return: numeric Description: Queries for the number of redbook (CD) devices Usage: %count = redbookGetDeviceCount;

redbookGetDeviceName(idx) Parameters: idx Device index Return: string Description: Queries the device name of redbook (CD) at the specified device index Usage: %name = redbookGetDeviceName(1);

redbookGetLastError Parameters: none Return: string Description: Queries for the last error from a redbook (CD) device Usage: %error = redbookGetLastError;

redbookGetTrackCount Parameters: none Return: numeric Description: Queries the number of redbook (CD) tracks Usage: %tracks = redbookGetTrackCount;

redbookGetVolume Parameters: none Return: numeric Description: Queries the current volume level of a redbook (CD) device Usage: %volume = redbookGetVolume;

redbookOpen([name]) Parameters: name If non-null, specifies the device Return: numeric 1 = success, 0 = fail Description: Opens a redbook (CD) device Usage: %result = redbookOpen;

redbookPlay(track) Parameters: track Index of track Return: numeric 1 = success, 0 = fail Description: Plays a track on a redbook (CD) device Usage: %result = redbookPlay(2);

redbookSetVolume(volume) Parameters: volume Volume setting Return: numeric 1 = success, 0 = fail Description: Sets the volume of a redbook (CD) device Usage: %result = redbookSetVolume(%volume);

redbookStop Parameters: none Return: numeric 1 = success, 0 = fail Description: Stops playing on the current redbook (CD) device Usage: %result = redbookStop;

removeField(text, index) Parameters: text String with field-delimited words index Field-based offset into the text string Return: string The resultant string Description: Removes the field-string at index from text Usage: %result = removeField(%text, 0);

removeRecord(text, index) Parameters: text String with new line-delimited records index Record-based offset into the text string Return: string The resultant string Description: Removes the record-string at index from text Usage: %str = removeRecord(%text, 0);

removeTaggedString(tag) Parameters: tag Numeric tag of string to be removed Return: nothing Description: Removes a tagged string from the list Usage: removeTaggedString(%tagname);

removeWord(text, index) Parameters: text String with space-delimited words index Word-based offset into the text string Return: string The resultant string Description: Removes the word-string at index from text Usage: %str = removeWord(%text, 0);

resetLighting Parameters: none Return: nothing Description: Resets the current lighting Usage: resetLighting;

restWords(text) Parameters: text String with space-delimited words Return: string The resultant string Description: Returns the words remaining after the first word in text Usage: %data = restWords(%text);

rtrim(str) Parameters: str String to be processed Return: string The processed resultant string Description: Strips any white space from str from the right side (after all other characters) of str. White space is defined as space, carriage returns, or new line characters. Usage: %tidystring = rtrim(%yuckystring);

saveJournal(name) Parameters: name String containing filename of journal Return: nothing Description: Save a journal to file specified by name Usage: saveJournal("myjrnl.jnl");

schedule(time, reference, function, ) Parameters: time Time to wait for trigger, in milliseconds reference Handle of object to attach schedule to, or 0 function Function to execute arg1...argN Arguments to accompany function (optional) Return: numeric Event ID Description: Schedules an event that will trigger in time milliseconds and execute function, with args. If reference is not 0, then it must be a valid object handle. If the object is deleted, the scheduled event is discarded. Usage: $evt = schedule(5000, 0, "updateRadar");

screenShot(filename) Parameters: filename String containing filename Return: nothing Description: Captures the screen view and saves it to file specified by filename Usage: screenShot("myScreen");

setClipboard(string) Parameters: string String containing text Return: nothing Description: Inserts the contents of string into the OS copy/paste clipboard Usage: setClipboard("A string of text");

setDefaultFov(fov) Parameters: fov Numeric in degrees Return: nothing Description: Sets the default field of view Usage: setDefaultFov(60);

setDisplayDevice(deviceName[, width[, height[, bpp[, fullScreen]]]] ) Parameters: deviceName Name of target device driver width Screen width height Screen height bpp Bits per pixel fullScreen 1 enables, 0 disables Return: numeric 1 = success, 0 = fail Description: Sets up the display device with specified values Usage: %result = setDisplayDevice("OpenGL", 800, 600, 32, true);

setEchoFileLoads(switch) Parameters: switch 1 (or true) enables, 0 (or false) disables Return: nothing Description: Enables or disables File Load echo to console Usage: setEchoFileLoads(1);

setField(text, index, subst) Parameters: text String with field-delimited words index Field-based offset into the text string subst Substitute string Return: string The resultant string Description: Substitutes the field-string sub for the word-string found at index in the string text Usage: %rec = setField(%text, 0, "blah");

setFov(val) Parameters: val The field of view (degrees) Return: nothing Description: Sets the current field of view Usage: setFov(90);

setFSAA(switch, level) Parameters: switch 1 enables, 0 disables level Target level Return: nothing Description: Enables or disables Full Screen Anti-Aliasing at specified level Usage: setFSAA(%newstate,%lvl)

setInteriorFocusedDebug(which) Parameters: which Handle of interior for focus. If which has a value, then debugging is enabled; if which is empty (not passed), then debugging is disabled. Return: nothing Description: Enables debug mode for interior focused objects Usage: setInteriorFocusedDebug;

setInteriorRenderMode(mode) Parameters: mode Return: nothing Description: Sets the detail render level for interiors Usage: setInteriorRenderMode(7);

setLogMode(mode) Parameters: mode The numeric mode value. Choices: 0 = no logging

1 = logging on, append mode

2 = logging on, overwrite mode Return: nothing Description: Enables or disables error logging to disk into the file name "console.log" Usage: setLogMode(1);

setModPaths(path) Parameters: path String containing path Return: nothing Description: Set Mod path. This specifies which folders will be visible to the scripts and the resource engine. Usage: setModPaths("common;game");

setNetPort(port) Parameters: port Port number Return: numeric 1 = success, 0 = fail Description: Sets the network port Usage: %result = setNetPort(1313);

setOpenGLAnisotropy(level) Parameters: level 0=trilinear, 1=bilinear Return: nothing Description: Sets the level of anisotropy Usage: setOpenGLAnisotropy(0);

setOpenGLInteriorMipReduction(level) Parameters: level Mipmap level (0 = minimum detail, 5 = maximum detail) Return: nothing Description: Sets interior texture detail Usage: setOpenGLInteriorMipReduction(2);

setOpenGLMipReduction(level) Parameters: level Mipmap level (0 = minimum detail, 5 = maximum detail) Return: nothing Description: Sets shape texture detail to level Usage: setOpenGLMipReduction(2);

setOpenGLSkyMipReduction(level) Parameters: level Mipmap level (0 = minimum detail, 5 = maximum detail) Return: nothing Description: Sets skybox and cloud texture detail Usage: setOpenGLMipReduction(2);

setOpenGLTextureCompressionHint(hint) Parameters: hint The compression level hint. Choices: GL_DONT_CARE

GL_FASTEST

GL_NICEST Return: nothing Description: Suggests texture compression mode Usage: setOpenGLTextureCompressionHint(GL_NICEST);

setPowerAudioProfiles(up, down) Parameters: up power up profile down power down profile Return: nothing Description: Set the ambient audio manager's power up/down profiles Usage: setPowerAudioProfiles(AudioPowerUpProfile, AudioPowerDownProfile);

setRandomSeed([seed]) Parameters: seed Starting point Return: nothing Description: Sets the current starting point for generating a series of pseudo-random numbers Usage: setRandomSeed;

setRecord (text, index, subst) Parameters: text String with new line-delimited records index Record-based offset into the text string subst Substitute string Return: string The resultant string Description: Substitutes the record-string sub for the record-string found at index in the string text Usage: %str = setRecord(%text, 0, "blah");

setRes(width, height, bpp) Parameters: width Screen width height Screen height bpp Bits per pixel Return: numeric 1 = success, 0 = fail Description: Sets the screen resolution to specified values Usage: %result = setRes(640,480,32);

setScreenMode(width, height, bpp, fullScreen) Parameters: width Screen width height Screen height bpp Bits per pixel fullScreen 1 enables, 0 disables Return: numeric 1 = success, 0 = fail Description: Sets up the screen with specified values Usage: %result = setScreenMode(800, 600, 32, true);

setServerInfo(index) Parameters: index Row of interest in the server list Return: numeric 1 = success, 0 = fail Description: Changes our indexed reference into the ServerList Usage: %result = setServerInfo(%index);

setShadowDetailLevel(level) Parameters: level Numeric range 0.0 to 1.0 Return: nothing Description: Sets the level of detail for shadows Usage: setShadowDetailLevel(1.0);

setVerticalSync(switch) Parameters: switch 1 enables, 0 disables Return: numeric 1 = true, 0 = false Description: Enables or disables the use of Vertical Sync Usage: setVerticalSync(true);

setWord(text, index, subst) Parameters: text String with space-delimited words index Word-based offset into the text string subst Substitute string Return: string The resultant string Description: Substitutes the word-string sub for the word-string found at index in the string text Usage: %str = setWord(%text, 0, "blah");

setZoomSpeed( speed ) Parameters: speed Transition speed. Ranges from 0 to 2,000 milliseconds. Return: nothing Description: Sets the transition speed when changing field of view Usage: setZoomSpeed( speed );

startHeartbeat Parameters: none Return: nothing Description: Begins periodic messages to the master server that show that this server is still alive Usage: schedule(0,0,startHeartbeat);

startClientReplication Parameters: none Return: nothing Description: Starts the client-side shape replicator running. Note that you must actually have the right kind of shapes (fxShapeReplicator) applied in a mission for this function to actually do anything. Usage: startClientReplication;

startFoliageReplication Parameters: none Return: nothing Description: Starts the client-side foliage replicator. This works the same way as the shape replicator described in startShapeReplication. Usage: startShapeReplication;

startRecording(filename) Parameters: filename String containing filename Return: nothing Description: Records a demo and saves it as filename Usage: startRecording(myDemo);

stopHeartbeat Parameters: none Return: nothing Description: Stops the heartbeat messages Usage: stopHeartbeat;

stopRecording Parameters: none Return: nothing Description: Stops the currently recording demo Usage: stopRecording;

stopServerQuery Parameters: none Return: nothing Description: Cancels the current query and marks outstanding pings as finished Usage: stopServerQuery;

strchr(str, char) Parameters: str String to be processed char String containing the character to be found Return: string Description: Finds the first substring in the string that begins with char Usage: %file = strchr("data/file.dat", "/" );

strcmp(str1, str2) Parameters: str1 First string str2 Second string Return: numeric < 0 str1 is less than (also not equal to) str2. 0 str1 is equal to str2. > 0 str1 is greater than (also not equal to) str2. Description: Case-sensitive comparison of two strings: str1 and str2 Usage: if(strcmp(%weaponName,"candlestick")==0) return %weaponFound;

stricmp(str1, str2) Parameters: str1 First string str2 Second string Return: numeric < 0 str1 is less than (also not equal to) str2. 0 str1 is equal to str2. > 0 str1 is greater than (also not equal to) str2. Description: Case-insensitive comparison of two strings: str1 and str2 Usage: if(stricmp(%weaponName,"CandleStick")==0) return %weaponFound;

stripChars(str, chars) Parameters: str String to be processed chars String containing characters to be stripped Return: string The processed resultant string Description: Removes all characters in the string chars from the string str Usage: %stripped = stripChars(%value, "~" );

stripMLControlChars(string) Parameters: string Return: string Description: Strips ML special control characters from string Usage: %text = stripMLControlChars(%string);

stripTrailingSpaces(string) Parameters: string Input string Return: string Description: Strips trailing spaces and underscores from string to be used for player name Usage: %name = stripTrailingSpaces(strToPlayerName( %name ) );

strlen(str) Parameters: str String Return: numeric Description: Obtains the number of characters in str Usage: %len = strlen(%weaponName);

strlwr(str) Parameters: str String to be processed Return: string The processed resultant string Description: Converts all characters in str to lowercase Usage: %var = strlwr(%value);

strpos(str, target[, offset]) Parameters: str String to be searched target String to find offset Starts search at offset (optional) Return: numeric Description: Finds the first occurrence of the target string in the search string, with optional starting offset. Note: This function is identical to strstr when offset isn't used. Usage: %pos = strpos(%weaponName, "gun") ;

strreplace(str, target, subst) Parameters: str String to be processed target Target string to be replaced subst Substitute string Return: string The processed resultant string Description: Replaces all instances of target and replaces with subst Usage: %dospath = strreplace(%path, "/", "\");

strstr(str, target) Parameters: str String to be tested target Target substring to find Return: numeric Offset within str where target was found Description: Finds first occurrence of a target within string Usage: %loc = strstr( %weaponName, "stick" );

strToPlayerName(string); Parameters: string Player name string Return: string Description: Converts name string to properly formatted player name string. Proper formatting means the player name is limited to 16 characters in length. Leading and trailing spaces are trimmed; reserved characters are removed. Usage: %newname = strToPlayerName( %name );

strupr(str) Parameters: str String to be processed Return: string The processed resultant string Description: Converts all characters in str to uppercase Usage: %var = strupr(%value);

switchBitDepth Parameters: none Return: numeric 1 = success, 0 = fail Description: Switches between 16 and 32 bits per pixel in full-screen mode Usage: %result = switchBitDepth;

telnetSetParameters(port, consolePW, listenPW) Parameters: port Connection port consolePW Console password listenPW "Listener" password Return: nothing Description: Initializes telnet connection request parameters Usage: telnetSetParameters(4123, "garage", "games");

toggleFullScreen Parameters: none Return: numeric 1 = success, 0 = fail Description: Switches between windowed mode and full-screen mode Usage: %result = toggleFullScreen;

toggleInputState Parameters: none Return: nothing Description: Toggles DirectInput state between enabled and disabled. Also prints the new input state (same as echoInputState) to the console. Usage: toggleInputState;

toggleLocking Parameters: none Return: nothing Description: Toggles UNIX/linux locking mechanism Usage: ToggleLocking;

trace(switch) Parameters: switch 1 (or true) enables, 0 (or false) disables Return: nothing Description: Turns execution trace on or off Usage: Trace(true);

trim(str) Parameters: str String to be processed Return: string The processed resultant string Description: Strips any white space from str from the left or right sides (before and after all other characters) of str. White space is defined as space, carriage returns, or new line characters. Usage: %tidystring = trim(%yuckystring);

validateMemory Parameters: none Return: nothing Description: Ensures sufficient memory available for the program Usage: validateMemory;

vectorAdd(vector1, vector2) Parameters: vector1 "x y z"  vector2 "x y z" Return: string Description: Adds vector2 to vector1 Usage: %result = vectorAdd("87.21 54.11 10.0", "9.99 12.6 6.00");

vectorCross(vector1, vector2) Parameters: vector1 "x y z"  vector2 "x y z" Return: string Description: Computes the cross product between two vectors Usage: %product = vectorCross("x y z","x y z");

vectorDist(vector1, vector2) Parameters: vector1 "x y z"  vector2 "x y z" Return: string Description: Computes the distance between two vectors Usage: %delta = vectorDist(%vector1, %vector2);

vectorDot(vector1, vector2) Parameters: vector1 "x y z"  vector2 "x y z" Return: string Description: Computes the dot product between two vectors Usage: %product = vectorDot("0 0 1",%eye);

vectorLen(vector) Parameters: vector "x y z" Return: string Description: Computes the length of the vector Usage: %len = vectorLen(vector);

vectorNormalize(vector) Parameters: vector "x y z" Return: string Description: Normalizes a vector Usage: %nvector = vectorNormalize("5 10 30");

vectorOrthoBasis(vector) Parameters: vector "x y z" Return: string Description: Computes the orthogonal normal for a vector Usage: %normal = vectorOrthoBasis("x y z angle");

vectorScale(vector, scalar) Parameters: vector "x y z"  scalar Can be an integer or a floating point Return: string Description: Computes the result of the vector sized by the scale Usage: %svector = vectorScale("5 10 30", 100);

vectorSub(vector1, vector2) Parameters: vector1 "x y z"  vector2 "x y z" Return: string Description: Subtracts vector2 from vector1 Usage: %result = vectorSub("34.0989 989.3249 100.00", %position);

videoSetGammaCorrection(gamma) Parameters: gamma Gamma correction setting Return: nothing Description: Sets the gamma correction Usage: videoSetGammaCorrection(0.5);

warn(text) Parameters: text String Return: nothing Description: Prints text to the console with light gray font. Text can be formatted according to the string rules. Usage: warn("Danger, Will Robinson!!");