Usage: SetRandomSeed; SetRecord text, index, subst Parameters: text String with new line-delimited records.. index Record-based offset into the text string.. Usage: StopHeartbeat; SetWor
Trang 1Torque Console Script Command Reference 717
SetOpenGLMipReduction(level)
Parameters: level Mipmap level (0 = minimum detail, 5 = maximum detail)
Return: nothingDescription: Sets shape texture detail to level
Usage: SetOpenGLMipReduction(2);
SetOpenGLSkyMipReduction(level)
Parameters: level Mipmap level (0 = minimum detail, 5 = maximum detail)
Return: nothingDescription: Sets skybox and cloud texture detail
Usage: SetOpenGLMipReduction(2);
SetRandomSeed([seed])
Parameters: seed Starting point
Return: nothingDescription: 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
Description: Suggests texture compression mode
Usage: SetOpenGLTextureCompressionHint(GL_NICEST);
Trang 2SetResolution(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: nothingDescription: 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);
Trang 3Torque Console Script Command Reference 719
SetZoomSpeed( speed )
Parameters: speed Transition speed Ranges from 0 to 2,000 milliseconds
Return: nothingDescription: Sets the transition speed when changing field of view
Usage: SetZoomSpeed( speed );
StartHeartbeat()
Parameters: noneReturn: nothingDescription: Begins periodic messages to the master server that show that this server is still
Usage: StartRecording(myDemo);
StopHeartbeat()
Parameters: noneReturn: nothingDescription: 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");
Trang 4Parameters: noneReturn: nothingDescription: Stops the currently recording demo
Usage: StopRecording();
StopServerQuery()
Parameters: noneReturn: nothingDescription: 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: stringDescription: Finds the first substring in the string that begins with char
Usage: %file = Strchr("data/file.dat", "/" );
Trang 5Torque Console Script Command Reference 721
> 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: stringReturn: stringDescription: Strips ML special control characters from string
Usage: %text = StripMLControlChars(%string);
StripTrailingSpaces(string)
Parameters: string Input string
Return: stringDescription: Strips trailing spaces and underscores from string to be used for player name
Usage: %name = StripTrailingSpaces( strToPlayerName( %name ) );
Strlen(str)
Parameters: str String
Return: numericDescription: Obtains the number of characters instr
Usage: %len = Strlen(%weaponName);
Trang 6Parameters: 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 strstrwhenoffset 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 oftarget 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" );
Trang 7Torque Console Script Command Reference 723
StrToPlayerName(string);
Parameters: string Player name string
Return: stringDescription: 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: noneReturn: 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: nothingDescription: Initializes telnet connection request parameters
Usage: TelnetSetParameters(4123, "garage", "games");
ToggleFullScreen()
Parameters: noneReturn: numeric 1 = success, 0 = fail
Description: Switches between windowed mode and full-screen mode
Usage: %result = ToggleFullScreen();
Trang 8Parameters: noneReturn: nothingDescription: TogglesDirectInputstate between enabled and disabled Also prints the new
input state (same as echoInputState) to the console
Usage: ToggleInputState();
ToggleNPatch()
Parameters: noneReturn: nothingDescription: Toggles the enable/disable state of Npatch.Usage: ToggleNPatch();
Trace(switch)
Parameters: switch 1 (or true) enables, 0 (or false) disables
Return: nothingDescription: 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: noneReturn: nothingDescription: Ensures sufficient memory available for the program
Usage: ValidateMemory();
Trang 9Torque Console Script Command Reference 725
VectorAdd(vector1, vector2)
Parameters: vector1 "x y z"
vector2 "x y z"
Return: stringDescription: Addsvector2 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: stringDescription: 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: stringDescription: Computes the distance between two vectors
Usage: %delta = VectorDist(%vector1, %vector2);
VectorDot(vector1, vector2)
Parameters: vector1 "x y z"
vector2 "x y z"
Return: stringDescription: Computes the dot product between two vectors
Usage: %product = VectorDot("0 0 1",%eye);
VectorLen(vector)
Parameters: vector "x y z"
Return: stringDescription: Computes the length of the vector
Usage: %len = VectorLen(vector);
Trang 10Parameters: vector "x y z"
Return: stringDescription: Normalizes a vector
Usage: %nvector = VectorNormalize("5 10 30");
VectorOrthoBasis(vector)
Parameters: vector "x y z"
Return: stringDescription: 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: stringDescription: 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: stringDescription: Subtractsvector2 from vector1
Usage: %result = VectorSub("34.0989 989.3249 100.00", %position);
VideoSetGammaCorrection(gamma)
Parameters: gamma Gamma correction setting
Return: nothingDescription: Sets the gamma correction
Usage: VideoSetGammaCorrection(0.5);
Trang 11Torque Reference Tables
Torque Reference Tables 727
Warn(text)
Parameters: text String
Return: nothingDescription: Printstext 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
Trang 12Table 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
Trang 13Torque Reference Tables 729
file.isEOF()file.readLine()file.close()FlyingVehicle FlyingVehicle.setCreateHeight(bool)GameBase obj.getDataBlock()
obj.setDataBlock(DataBlock)GameConnection conn.chaseCam(size)
conn.setControlCameraFov(fov)conn.getControlCameraFov()conn.transmitDataBlocks(seq)conn.activateGhosting()conn.resetGhosting()conn.setControlObject(%obj)conn.getControlObject()conn.isAIControlled()conn.play2D(AudioProfile)conn.play3D(AudioProfile,Transform)conn.isScopingCommanderMap()conn.scopeCommanderMap(bool)conn.listenEnabled()
conn.getListenState(clientId)conn.canListen(clientId)conn.listenTo(clientId, true|false)conn.listenToAll()
conn.listenToNone()conn.setVoiceChannels(0-3)conn.setVoiceDecodingMask(mask)conn.setVoiceEncodingLevel(codecLevel)conn.setBlackOut(fadeTOBlackBool, timeMS)conn.setMissionCRC(crc)
GuiBitmapCtrl guiBitmapCtrl.setBitmap(blah)
guiBitmapCtrl.setValue(xAxis, yAxis)GuiCanvas canvas.renderFront(bool)
canvas.setContent(ctrl)canvas.getContent()canvas.pushDialog(ctrl)canvas.popDialog()canvas.popLayer()canvas.cursorOn()canvas.cursorOff()canvas.setCursor(cursor)
continued
Trang 14canvas.hideCursor()canvas.showCursor()canvas.repaint()canvas.reset()canvas.isCursorOn()canvas.getCursorPos()canvas.setCursorPos(pos)GuiControl ctrl.getPosition()
ctrl.getExtent()ctrl.getMinExtent()ctrl.resize(x, y, w, h)ctrl.setValue(value)ctrl.getValue()ctrl.setActive(value)ctrl.isActive()ctrl.setVisible(value)ctrl.isVisible()ctrl.isAwake()ctrl.setProfile(profile)ctrl.makeFirstResponder(value)GuiEditCtrl editCtrl.addNewCtrl(ctrl)
editCtrl.select(ctrl)editCtrl.setRoot(root)editCtrl.setCurrentAddSet(ctrl)editCtrl.toggle()
editCtrl.justify(mode)editCtrl.bringToFront()editCtrl.pushToBack()editCtrl.deleteSelection()GuiFilterCtrl guiFilterCtrl.getValue()
guiFilterCtrl.setValue(f1, f2, )guiFilterCtrl.identity()GuiFrameSetCtrl gfsc.frameBorder(index, enable)
gfsc.frameMovable(index, enable)gfsc.frameMinExtent(index, w, h)GuiInspector inspector.inspect(obj)
inspector.apply(newName)GuiMessageVectorCtrl [GuiMessageVectorCtrl].attach(MessageVectorId)
[GuiMessageVectorCtrl].detach()GuiPopUpMenuCtrl menu.sort()
menu.add(name,idNum{,scheme})
continued
Trang 15Torque Reference Tables 731
menu.addScheme(id, fontColor, fontColorHL, fontColorSEL)menu.getText()
menu.setText(text)menu.getValue()menu.setValue(text)menu.clear()menu.forceOnAction()menu.forceClose()menu.getSelected()menu.setSelected(id)menu.getTextById(id)menu.setEnumContent(class, enum)menu.findText(text)
menu.size()menu.replaceText(bool)GuiSliderCtrl guiSliderCtrl.getValue()GuiTerrPreviewCtrl guiTerrPreviewCtrl.reset()
guiTerrPreviewCtrl.setRoot()guiTerrPreviewCtrl.getRoot()guiTerrPreviewCtrl.setOrigin(x, y)guiTerrPreviewCtrl.getOrigin()guiTerrPreviewCtrl.getValue()guiTerrPreviewCtrl.getValue(t)GuiTextListCtrl textList.getSelectedId()
textList.setSelectedById(id)textList.setSelectedRow(index)textList.clearSelection()textList.clear()textList.addRow(id,text,index)textList.setRow(id,text)textList.getRowId(index)textList.removeRowById(id)textList.getRowTextById(id)textList.getRowNumById(id)textList.getRowText(index)textList.removeRow(index)textList.rowCount()textList.scrollVisible(index)textList.sort(colId{,increasing})textList.sortNumerical(colId{, increasing})textList.findText(text)
continued
Trang 16textList.setRowActive(id)textList.isRowActive(id)GuiTreeViewCtrl treeViewCtrl.open(obj)HTTPObject obj.get(addr, request-uri)
obj.post(addr, request-uri, query, post)InteriorInstance [InteriorObject].activateLight()
[InteriorObject].deactivateLight()[InteriorObject].echoTriggerableLights()[InteriorObject].getNumDetailLevels()[InteriorObject].setDetailLevel(level)Item obj.isStatic()
obj.isRotating()obj.setCollisionTimeout(object)obj.getLastStickyPos()obj.getLastStickyNormal()Lightning [LightningObject].warningFlashes()
[LightningObject].strikeRandomPoint()[LightningObject].strikeObject(id)MessageVector [MessageVector].deleteLine(DeletePos)
[MessageVector].clear()[MessageVector].dump(filename{, header})[MessageVector].getNumLines()
[MessageVector].getLineText(Line)[MessageVector].getLineTag(Line)[MessageVector].getLineTextByTag(Tag)[MessageVector].getLineIndexByTag(Tag)PhysicalZone obj.activate()
obj.deactivate()Player obj.setActionThread(sequenceName)
obj.setControlObject(obj)obj.getControlObject()obj.clearControlObject()obj.getDamageLocation(pos)Precipitation precipitation.setPercentage(percentage <1.0 to 0.0>)
precipitation.stormPrecipitation(percentage <0 to 1>, Time)SceneObject obj.getScale()
obj.getWorldBox()obj.getWorldBoxCenter()obj.getObjectBox()obj.getForwardVector()ShapeBase obj.setShapeName(tag)
continued