Contents

Console Objects Fields and Methods Quick Reference Part 11


This quick reference guide was taken directly out of The Game Programmer's Guide to Torque by Edward Maurina. It's an outstanding resource - a must for anyone wanting to get serious about programming in Torque.

ScriptBase Cntd.




Console Methods Cntd.


Velocity

getVelocity() setVelocity()


getVelocity()

Purpose
Use the getVelocity method to get the current velocity of this shape.

Returns
Returns an XYZ vector equivalent to the magnitude and direction of this shape's movement.

See Also
applyImpulse, setVelocity



setVelocity( velocity )

Purpose
Use the setVelocity method to set this shape's current velocity.

Syntax
veclocity
– An XYZ vector equivalent to the new magnitude and direction of this shape's movement.

Returns
Returns true on success, false on failure.

Notes
It is sometimes nicer to use this method than applyImpluse because with this we can ignore a shape's mass while with applyImpluse mass directly affects the end velocity of the shape.

See Also
appyImpulse, getVelocity


Impulses

applyImpulse


applyImpulse( position , impulseVector )

Purpose
Use the applyImpulse method to apply an instantaneous acceleration to a shape at world position.


Syntax
position
– An XYZ vector specifying the position at which to apply the impulse.
impulseVector – An XYZ vector encoding the magnitude and direction of the impulse.

Returns
No return value.

Notes
To apply an impulse, the shape must have a non-zero positive mass, or applying an impulse will crash the engine. Also, applying an impulse whose magnitude is greater than or equal to about 40 times the mass of a shape may cause the engine to lock up temporarily.

See Also
setVelocity


Camera Settings

getCameraFOV setCameraFOV


getCamerFOV( )

Purpose
Use the getCamerFOV method to get the current field-of-view FOV.

Returns
Returns the current FOV setting, a value between 0.0 and 180.0

See Also
setCameraFOV



setCamerFOV( FOV )

Purpose
Use the setCamerFOV method to set the current field-of-view (FOV) if this is a camera shape, or if a camera shape is using this shape to get it's FOV setting.

Syntax
FOV
– Field-of-view. A flaoting-point value between 0.0 and 180.0.

Returns
No return value.

Notes
Changing the FOV will make the view zoom in and out, depending on the setting. i.e. If we start at an default FOV of 90.0 and increase it to 270.0, the scene will zooom out. If we change it to 35.0 it will zoom in.

See Also
getCameraFOV


Animations

pauseThread playThread setThreadDir stopThread


pauseThread( thread )

Purpose
Use the pauseThread method to pause a currently playing animation.

Syntax
thread
– An integer value between 0 and 3 specifying a previously started animation sequence.

Returns
Returns true if there was a previous thread playing, false otherwise.

See Also
playThread, stopThread



playThread( thread , sequenceName )

Purpose
Use the playThread method to play a new sequence specified by sequenceName in the animation thread.

Syntax
thread
– An integer value between 0 and 3 specifying a thread/slot to start this animation in.
sequenceName – A valid animation name for the mesh this shape is using.

Returns
Returns true if the thread was successfully started, otherwise returns false.

Notes
Playing an new animation in a thread that already has an active animation will stop the active animation and reset affected nodes to their pre-animation positions.

See Also
pauseThread, setThreadDir, stopThread



setThreadDir( thread , forward )

Purpose
Use the setThreadDir method to set the direction a specific thread should be played in.

Syntax
thread
– An integer value between 0 and 3 specifying a previously started animation sequence.
forward – A boolean value. If set to true, the animation will play forward, otherwise it will play in reverse.

Returns
Returns true if the direction could be set for the specified thread, otherwise returns false.

Notes
A thread needs to have already been started for this to work, but after that this will work on any sequence whether it be already completed, or a cyclic animation that never ends.

See Also
pauseThread, playThread, stopThread



stopThread( thread )

Purpose
Use the stopThread method to stop a previousl started sequence from playing.

Syntax
thread
– An integer value between 0 and 3 specifying a previously started animation sequence.

Returns
Returns true if the thread was successfully stopped, otherwise returns false.

See Also
pauseThread, playThread, setThreadDir


Sound

playAudio stopAudio


playAudio( thread , audioProfile )

Purpose
Use the playAudio method to play a sound specified by audioProfile in the slot specified by thread.

Syntax
thread
– An integer value between 0 and 3 specifying a slot to play the sound in.
audioProfile – An audioprofile datablock previously created using the datablocks keyword, not the new keyword.

Returns
Returns true if the sound was successfully started, otherwise returns false.

Notes
Be sure to only use audioProfiles made using the datablock keyword or the sounds will not play on remote clients.

See Also
stopAudio



stopAudio( thread )

Purpose
Use the stopAudio method to stop a previously started audio thread.

Syntax
thread
– An integer value between 0 and 3 specifying a slot in which a sound was previously started.

Returns
Returns true if the sound was successfully stopped, otherwise returns false.

See Also
playAudio


Mounting

getMountedImage getMountedObjectCount getMountedObjectNode
getMountNodeObject getMountSlot getMountedObject
getObjectMount getPendingImage getSlotTransform
isImageMounted isMounted mountImage
mountObject unmount unmountImage
unmountObject


getMountedImage( slot )

Purpose
Use the getMountedImage method to get the datablock ID of the image mounted in slot.

Syntax
slot
– An integer value between 0 and 7 representing a mount slot on this shape.

Returns
Returns the datablock ID of the image mounted in slot, or zero if no image is mounted.

Notes
Do not confuse slots with mount nodes. A shape can have up to 32 mount nodes, but only has eight mount slots. Mount nodes are points on the mesh used by the shape while slots are used to track how many objects and images are mounted to a shape.

See Also
isImageMounted, mountImage, unmountImage



getMountedObjectCount()

Purpose
Use the getMountedObjectCount method to determine how many objects are currently mounted to this shape.

Returns
Returns an integer between 0 and 8 representing the number of objects that are mounted to this shape.

Notes
A shape may have at most eight objects mounted to it at any one time.

This method does not count images that are mounted to the shape.

See Also
mountObject, unmountObject



getMountedObjectNode( slot )

Purpose
Use the getMountedObjectNode method to determine the mount node index of an object mounted in slot.

Syntax
slot
– An integer value between 0 and 7 representing a mount slot on this shape.

Returns
Returns a numberic value between 0 and 31 if an object is mounted is slot, otherwise returns -1.

Notes
Do not confuse slots with mount nodes. A shape can have up to 32 mount nodes, but only has eight mount slots. Mount nodes are points on the mesh used by the shape while slots are used to track how many objects and images are mounted to a shape.

See Also
getMountNodeObject


Return the mount node used by the object/image mounted at slot.



getMountNodeObject( node )

Purpose
Use the getMountNodeObject method to get the ID of the object mountd at mount node.

Syntax
node
– A node value between 0 and 31 representing a mount node in the mesh used by this shape.

Returns
Returns an integer value equal to the ID of the object mounted on node. If not object is mounted at node, this method returns -1.

Notes
Do not confuse slots with mount nodes. A shape can have up to 32 mount nodes, but only has eight mount slots. Mount nodes are points on the mesh used by the shape while slots are used to track how many objects and images are mounted to a shape.

See Also
getMountedObjectNode



getMountSlot( imageHandle )

Purpose
Use the getMountSlot method to determine what slot the image datablock specified by imageHandle is mounted in.

Syntax
imageHandle
– The name of ID of a ShapeBaseImageData datablock.

Returns
Returns a value between 0 and 7 if imageHandle is mounted to this shape, or -1 if it is not.



getMountedObject( slot )

Purpose
Use the getMountedObject method to get the ID of the object mountd at mount slot.

Syntax
slot
– An integer value between 0 and 7 representing a mount slot on this shape.

Returns
Returns an integer value equal to the ID of object mounted is slot. If not object is mounted in this slot, the method returns -1.

Notes
Do not confuse slots with mount nodes. A shape can have up to 32 mount nodes, but only has eight mount slots. Mount nodes are points on the mesh used by the shape while slots are used to track how many objects and images are mounted to a shape.

See Also
getMountedObjectNode



getObjectMount()

Purpose
Use the getObjectMount method to get the ID of the object this object is mounted to.

Returns
Returns an integer value representing the ID of an object that this shape is mounted to, or 0 if this object is not mounted to another object.



getPendingImage( slot )

Purpose
Use the getPendingImage method to get the ID of an image that is pending for slot.

Syntax
slot
– An integer value between 0 and 7 representing a mount slot on this shape.

Returns
Returns an integer value representing the ID of a shapeBaseImageData object that is pending for slot. If no image is pending, returns 0.


Notes
Do not confuse slots with mount nodes. A shape can have up to 32 mount nodes, but only has eight mount slots. Mount nodes are points on the mesh used by the shape while slots are used to track how many objects and images are mounted to a shape.



getSlotTransform( slot )

Purpose
Use the getSlotTransform method to get the transform the specified slot.

Syntax
slot
– An integer value between 0 and 7 representing a mount slot on this shape.

Returns
Returns a seven-element floating-point vector representing the transform of the node that an object tracked in slot is mounted to. i.e. Once we have a shape mounted to another shape, we can determine what slot the shape is tracked in and then get the tranform for the node that is being used for the mount.

Notes
Do not confuse slots with mount nodes. A shape can have up to 32 mount nodes, but only has eight mount slots. Mount nodes are points on the mesh used by the shape while slots are used to track how many objects and images are mounted to a shape.



isImageMounted( imageHandle )

Purpose
Use the isImageMounted method to determine if the shapeBaseImageData specified by imageHandle is mounted on this shape.

Syntax
imageHandle
– The datablock ID of a shapeBaseImageData object to check for.

Returns
Returns true if the specified image is mounted to this shape, otherwise returns false.



isMounted()

Purpose
Use the isMounted method to see if this object is mounted to another shape.

Returns
Returns true if this shape is mounted to another shape, otherwise returns false.



mountImage( imageHandle, slot [ , loaded [ , skinName ] ] )

Purpose
Use the mountImage method to mount the image specified by imageHandle to this image, using slot. Optinally, this image can be set to the 'loaded' state and given an alternate skinName.

Syntax
imageHandle
– The ID or name of a valid shapeBaseImageData datablock.
slot – An integer value between 0 and 7 representing a mount slot on this shape.
loaded – A boolean value. If set to true, the image the image's loaded state will be true.
skinName – A optional skin tag used to specify a specialized 'team' skin for the image.

Returns
Returns true on success, false otherwise.

Notes
Do not confuse slots with mount nodes. A shape can have up to 32 mount nodes, but only has eight mount slots. Mount nodes are points on the mesh used by the shape while slots are used to track how many objects and images are mounted to a shape.

Don't forget. Images specify the node that the mount to in their 'mountPoint' field.

See Also
mountObject



mountObject( objectHandle , node )

Purpose
Use the mountObject method to mount the shape specified by objectHandle to this shape at mount node.

Syntax
objectHandle
– The ID or name of the shape to mount to this shape.
node – The mount node on this shape's mesh upon which to mount the shape.

Returns
Returns true on a successful mount, otherwise returns false.

Notes
Do not confuse slots with mount nodes. A shape can have up to 32 mount nodes, but only has eight mount slots. Mount nodes are points on the mesh used by the shape while slots are used to track how many objects and images are mounted to a shape.

See Also
mountImage



unmount()

Purpose
Use the unmount method to force this object to be unmounted from a shape it is mounted to.

Returns
No return value.

See Also
unmountImage, unMountObject



unmountImage( slot )

Purpose
Use the unmountImage method to unmount an image mounted to this shape in slot.

Syntax
slot
– An integer value between 0 and 7 representing a mount slot on this shape.

Returns
Returns true if the image was unmounted successfully, otherwise returns false if no image was present in that slot. Images cannot 'resist' unmounting.

Notes
Do not confuse slots with mount nodes. A shape can have up to 32 mount nodes, but only has eight mount slots. Mount nodes are points on the mesh used by the shape while slots are used to track how many objects and images are mounted to a shape.

See Also
unmountObject



unmountObject( objectHandle )

Purpose
Use the unmountObject method to cause the object specified by objectHandle to unmount from this shape.

Syntax
objectHandle
– The ID or name of an object mounted to this shape.

Returns
Returns true if objectHandle is in fact mounted to this shape and is then unmounted by this method. Returns false if objectHandle is not mounted to this shape.

See Also
unmountImage


The Control Object

getControllingClient() getControllingObject()


getControllingClient()

Purpose
Use the getControllingClient method to get the ID of the client controlling this shape.

Returns
Returns the ID of the GameConnection (client) controlling this shape, or 0 if no client is controlling this shape.

See Also
getControllingObject



getControllingObject()

Purpose
Use the getControllingObject method to get the ID of the object controlling this object. Shapes may controlled by other shapes by having the controlling shape pass commands sent to it from the client to a surrogate object instead. i.e. Object A can be controlled by the client and send movement inputs to object B, in effect controlling object B.

Returns
Returns the ID of the shape controlling this object, otherwise if no object is controlling this shape returns 0.

The playe class has methods for setting up control of other shapes.


Table of Contents || Part 1 || Part 2 || Part 3 || Part 4 || Part 5 || Part 6 || Part 7 || Part 8 || Part 9 || Part 10 || Part 12 || Part 13 || Part 14 || Part 15