Tải bản đầy đủ (.pdf) (30 trang)

3D Game Programming All in One- P28

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (304.75 KB, 30 trang )

Torque Console Script Command Reference 717
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);
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");
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);
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Appendix A

The Torque Game Engine Reference718

SetResolution(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 = SetResolution(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
VerticalSync
.

Usage:
SetVerticalSync(true);
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Torque Console Script Command Reference 719
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);
StartRecording(filename)
Parameters: filename
String containing file name.
Return: nothing
Description:
Records a demo and saves it as f
ilename
.
Usage:

StartRecording(myDemo);
StopHeartbeat()
Parameters: none
Return: nothing
Description:
Stops the heartbeat messages.
Usage:
StopHeartbeat();
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");
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Appendix A


The Torque Game Engine Reference720
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;
Team LRN

Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Torque Console Script Command Reference 721
Stricmp(str1, str2)
Parameters: str1
First string.
str2
Second string.
Return: numeric
< 0
str1
is less than (not equal to)
str2
.
0
str1
is equal to
str2
.
> 0
str1
is greater than (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);
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Appendix A

The Torque Game Engine Reference722
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" );
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Torque Console Script Command Reference 723
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();
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Appendix A

The Torque Game Engine Reference724
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();
ToggleNPatch()
Parameters: none
Return: nothing
Description:
Toggles the enable/disable state of
Npatch
.
Usage:
ToggleNPatch();
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();
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Torque Console Script Command Reference 725
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);
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Appendix A

The Torque Game Engine Reference726
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);
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Torque Reference Tables
Torque Reference Tables 727
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!!");
Table A.1 Torque Script Object Type Masks
Mask Identifier Number Mask Bit Position
DefaultObjectType 0 0
StaticObjectType 1 1
EnvironmentObjectType 2 2
TerrainObjectType 4 3
InteriorObjectType 8 4

WaterObjectType 16 5
TriggerObjectType 32 6
MarkerObjectType 64 7
unassigned
128 8
unassigned
256 9
DecalManagerObjectType 512 10
GameBaseObjectType 1024 11
ShapeBaseObjectType 2048 12
CameraObjectType 4096 13
StaticShapeObjectType 8192 14
PlayerObjectType 16384 15
ItemObjectType 32768 16
VehicleObjectType 65536 17
VehicleBlockerObjectType 131072 18
ProjectileObjectType 262144 19
ExplosionObjectType 524288 20
unassigned
2097152 21
CorpseObjectType 1048576 22
DebrisObjectType 4194304 23
PhysicalZoneObjectType 8388608 24
unassigned 33554432 25
StaticTSObjectType 16777216 26
continued
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Appendix A


The Torque Game Engine Reference728
StaticRenderedObjectType 67108864 27
unassigned
268435456 28
unassigned
536870912 29
unassigned
1073741824 30
unassigned
2147483648 31
Table A.2 Torque Object Methods
Object Class Method
AIPlayer ai.moveForward()
ai.walk()
ai.run()
ai.stop()
ai.setMoveSpeed(float)
ai.setTargetObject(object)
ai.getTargetObject()
ai.targetInSight()
ai.aimAt( point)
ai.getAimLocation()
BanList BanList::add(id, TA, banTime)
BanList::addAbsolute(id, TA, banTime)
BanList::removeBan(id, TA)
BanList::isBanned(id, TA)
BanList::export(filename)
Camera camera.getPosition()
camera.setOrbitMode(obj, xform,min-dist,max-dist, cur-dist)
camera.setFlyMode()

watchView.edit(newValue)
watchView.remove()
watchView.queryAll()
watchView.clear()
Debris obj.init(position, velocity)
EditTSCtrl EditTSCtrl.renderSphere(pos, radius,=)
EditTSCtrl.renderCircle(pos, normal, radius,=)
EditTSCtrl.renderTriangle(pnt, pnt, pnt)
EditTSCtrl.renderLine(start, end)
FileObject file.openForRead(fileName)
file.openForWrite(fileName)
file.openForAppend(fileName)
file.writeLine(text)
continued
Team LRN
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

×