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

3D Game Programming All In One (2004)

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

698 Appendix A The Torque Game Engine Reference

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

Return:

numeric

1 = true, 0 = false.

Description:

Queries if file specified by filename is writeable.

Usage:

%result = IsWriteableFileName("/common/server/script.cs");

Team LRN

 

 

 

Torque Console Script Command Reference

699

 

 

 

 

 

LaunchDedicatedServer(missionType, map, botCount )

 

 

 

Parameters:

missionType

Gameor Mod-specific string.

 

 

 

map

Mission or map name string.

 

 

 

botCount

Number of AI bots allowed.

 

 

Return:

nothing

 

 

 

 

Description:

Starts dedicated game server with specified arguments.

 

 

Usage:

LaunchDedicatedServer(mymission,damap,0);

 

 

 

 

 

 

 

 

 

 

 

 

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

 

 

 

 

 

 

 

Team LRN

700

Appendix A

The Torque Game Engine Reference

 

 

 

 

 

 

 

 

mAcos(x)

 

 

 

 

 

Parameters:

x

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

 

 

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

Radian. Can be an integer or a floating point.

 

 

Return:

numeric

 

 

 

 

Description:

Computes the arc tangent.

 

 

Usage:

%val = mAtan(-1.667,2);

 

 

 

 

 

 

Team LRN

Torque Console Script Command Reference 701

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

Team LRN

702

Appendix A

The Torque Game Engine Reference

 

 

 

 

 

 

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

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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

Team LRN

 

 

 

Torque Console Script Command Reference

703

 

 

 

 

 

 

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

 

 

 

 

 

 

 

Team LRN

704

Appendix A

The Torque Game Engine Reference

 

 

 

 

 

 

 

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

Team LRN

 

 

 

Torque Console Script Command Reference

705

 

 

 

 

 

 

 

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

 

 

 

 

 

 

 

Team LRN

706 Appendix A The Torque Game Engine Reference

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

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

Team LRN

 

 

Torque Console Script Command Reference

707

 

 

 

 

 

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

Return:

nothing

 

Description:

Plays back a demo saved in filename.

Usage:

PlayDemo(MyNiftyDemo);

PlayJournal(name,[break])

Parameters:

name

String containing file name 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");

PrevResolution()

Parameters:

none

 

Return:

numeric

1 = success, 0 = fail.

Description:

Decreases next highest resolution.

Usage:

%result = PrevResolution();

Team LRN