Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

3D Game Programming All In One (2004)

.pdf
Скачиваний:
139
Добавлен:
17.08.2013
Размер:
17.91 Mб
Скачать

678 Appendix A The Torque Game Engine Reference

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 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 file name.

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);

Team LRN

 

 

 

Torque Console Script Command Reference

679

 

 

 

 

 

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. 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:

Find the next object in the container specified by immediately previous call to

 

 

 

containerFindFirst, and get 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();

Team LRN

680 Appendix A The Torque Game Engine Reference

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();

Team LRN

 

 

 

Torque Console Script Command Reference

681

 

 

 

 

 

 

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();

Team LRN

682 Appendix A The Torque Game Engine Reference

DecreaseFSAA()

Parameters:

none

Return:

nothing

Description:

Invokes DecreaseNPatch.

Usage:

DecreaseFSAA ()

DecreaseNPatch()

Parameters: none

Return: nothing

Description: Decrements Npatch level by 1.

Usage: DecreaseNPatch():

DeleteDataBlocks()

Parameters: none

Return: nothing

Description: Unloads and removes all registered datablocks 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);

Team LRN

Torque Console Script Command Reference 683

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 file name.

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();

Team LRN

684

Appendix A

The Torque Game Engine Reference

 

 

 

 

 

 

 

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 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();

EnableMouse()

Parameters:

none

 

Return:

numeric

1 = success, 0 = fail.

Description:

Enables DirectInput polling of the mouse device.

Usage:

%result = EnableMouse();

Team LRN

 

 

 

Torque Console Script Command Reference

685

 

 

 

 

 

 

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.");

 

 

 

 

 

 

 

Exec(fileName [, nocalls ])

Parameters:

filename

String containing file name.

 

nocalls

When set to true, prevents functions from being called.

Return:

string

 

Description:

Compiles, executes functions, assigns variables, and loads packages and data

 

blocks within 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 file name.

Return: string

Description: Obtains the actual OS-specific absolute path of filename.

Usage: %fullmissionpath = ExpandFilename("~/data/missions/test.mis");

Team LRN

686 Appendix A The Torque Game Engine Reference

Export(searchString [, fileName [,append]])

Parameters:

search

Prefix of variables to search for.

 

filename

String containing file name.

 

append

Indicates whether to append to file or overwrite.

Return:

nothing

 

Description:

Saves the values of variables starting with search to the file named 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 file name.

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 file name.

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 file name.

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 file name.

Return:

string

String containing the path.

Description:

Gets the path of the file specified by filename.

Usage:

%path = FilePath("/common/server/script.cs");

Team LRN

 

 

 

Torque Console Script Command Reference

687

 

 

 

 

 

 

FindFirstFile (pattern)

 

 

 

 

Parameters:

pattern

String pattern.

 

 

Return:

string

The file's name.

 

 

Description:

Finds the name of the first file in the Torque Script file name 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 Torque Script filename buffer matching the

 

 

 

search by immediately previous call to 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();

Team LRN