Torque 3D - Script Manual: Game

TorqueScript

Main   Class List   Namespace List   Online

Game

This section includes all objects, functions, and variables related to game play elements exposed by Torque 3D. More...

Classes

class  SimObject
 Base class for almost all objects involved in the simulation. More...

Modules

 Game Objects
 

Objects which can be controlled or directly interact with a user, such as Player, Projectile, Item, etc.


 Special Effects
 

Classes responsible for special effect objects, such as Explosion, Debris, Particles, etc.


 AI
 

Classes and functions related to artificial intelligence for Torque 3D.


 Miscellaneous
 

Miscellaneous/uncategorized game related objects.


 Physics
 

Objects and functions related to Torque 3D's physics layer.


 Vehicles
 

This section is dedicated to vehicle game objects, such as the base Vehicle class, WheeledVehicle, FlyingVehicle, and so on.


Functions

bool addBadWord (string badWord)
 Add a string to the bad word filter.
bool containerBoxEmpty (int mask, Point3F center, float xRadius, float yRadius=-1, float zRadius=-1, bool useClientContainer=false)
 See if any objects of the given types are present in box of given extent.
string containerFindFirst (int mask, Point3F point, float x, float y, float z)
 Find objects matching the bitmask type within a box centered at point, with extents x, y, z.
string containerFindNext ()
 Get more results from a previous call to containerFindFirst().
string containerRayCast (Point3F start, Point3F end, int mask, SceneObject pExempt=NULL, bool useClientContainer=false)
 Cast a ray from start to end, checking for collision against items matching mask.
float containerSearchCurrDist (bool useClientContainer=false)
 Get distance of the center of the current item from the center of the current initContainerRadiusSearch.
float containerSearchCurrRadiusDist (bool useClientContainer=false)
 Get the distance of the closest point of the current item from the center of the current initContainerRadiusSearch.
SceneObject containerSearchNext (bool useClientContainer=false)
 Get next item from a search started with initContainerRadiusSearch() or initContainerTypeSearch().
bool containsBadWords (string text)
 Checks to see if text is a bad word.
string filterString (string baseString=NULL, string replacementChars=NULL)
 Replaces the characters in a string with designated text.
void initContainerRadiusSearch (Point3F pos, float radius, int mask, bool useClientContainer=false)
 Start a search for items at the given position and within the given radius, filtering by mask.
void initContainerTypeSearch (int mask, bool useClientContainer=false)
 Start a search for all items of the types specified by the bitset mask.
bool isPointInside (Point3F position)
 Check to see if a point in world space is inside of an interior.
bool isPointInside (F32 x, F32 y, F32 z)
void resetFPSTracker ()
 Reset FPS stats (fps::).
void sceneDumpZoneStates (bool updateFirst=true)
 Dump the current zoning states of all zone spaces in the scene to the console.
SceneObject sceneGetZoneOwner (int zoneId=true)
 Return the SceneObject that contains the given zone.
void setInteriorRenderMode (int mode)
 Globally changes how InteriorInstances are rendered. Useful for debugging geometry and rendering artifacts.
bool spawnObject (class[, dataBlock, name, properties, script])
 Global function used for spawning any type of object.

Variables

float $cameraFov
 The camera's Field of View.
float $mvBackwardAction
 Backwards movement speed for the active player.
bool $mvDeviceIsKeyboardMouse
 Boolean state for it the system is using a keyboard and mouse or not.
float $mvDownAction
 Downwards movement speed for the active player.
float $mvForwardAction
 Forwards movement speed for the active player.
bool $mvFreeLook
 Boolean state for if freelook is active or not.
float $mvLeftAction
 Left movement speed for the active player.
float $mvPitch
 Current pitch value, typically applied through input devices, such as a mouse.
float $mvPitchDownSpeed
 Downwards pitch speed.
float $mvPitchUpSpeed
 Upwards pitch speed.
float $mvRightAction
 Right movement speed for the active player.
float $mvRoll
 Current roll value, typically applied through input devices, such as a mouse.
float $mvRollLeftSpeed
 Left roll speed.
float $mvRollRightSpeed
 Right roll speed.
int $mvTriggerCount0
 Used to determine the trigger counts of buttons. Namely used for input actions such as jumping and weapons firing.
int $mvTriggerCount1
 Used to determine the trigger counts of buttons. Namely used for input actions such as jumping and weapons firing.
int $mvTriggerCount2
 Used to determine the trigger counts of buttons. Namely used for input actions such as jumping and weapons firing.
int $mvTriggerCount3
 Used to determine the trigger counts of buttons. Namely used for input actions such as jumping and weapons firing.
int $mvTriggerCount4
 Used to determine the trigger counts of buttons. Namely used for input actions such as jumping and weapons firing.
int $mvTriggerCount5
 Used to determine the trigger counts of buttons. Namely used for input actions such as jumping and weapons firing.
float $mvUpAction
 Upwards movement speed for the active player.
float $mvXAxis_L
 Left thumbstick X axis position on a dual-analog gamepad.
float $mvXAxis_R
 Right thumbstick X axis position on a dual-analog gamepad.
float $mvYaw
 Current yaw value, typically applied through input devices, such as a mouse.
float $mvYawLeftSpeed
 Left Yaw speed.
float $mvYawRightSpeed
 Right Yaw speed.
float $mvYAxis_L
 Left thumbstick Y axis position on a dual-analog gamepad.
float $mvYAxis_R
 Right thumbstick Y axis position on a dual-analog gamepad.
int $Ease::Back
 Backwards ease for curve movement.
int $Ease::Bounce
 Bounce ease for curve movement.
int $Ease::Circular
 Circular ease for curve movement.
int $Ease::Cubic
 Cubic ease for curve movement.
float $pref::Camera::distanceScale
 A scale to apply to the normal visible distance, typically used for tuning performance.
int $Ease::Elastic
 Elastic ease for curve movement.
bool $pref::enableBadWordFilter
 If true, the bad word filter will be enabled.
bool $pref::enablePostEffects
 If true, post effects will be eanbled.
int $Ease::Exponential
 Exponential ease for curve movement.
int $Ease::In
 In ease for curve movement.
int $Ease::InOut
 InOut ease for curve movement.
bool $pref::Input::JoystickEnabled
 If true, the joystick is currently enabled.
int $Ease::Linear
 Linear ease for curve movement.
int $Ease::Out
 Out ease for curve movement.
int $Ease::Quadratic
 Quadratic ease for curve movement.
int $Ease::Quartic
 Quartic ease for curve movement.
int $Ease::Quintic
 Quintic ease for curve movement.
int $Ease::Sinusoidal
 Sinusoidal ease for curve movement.

Detailed Description

This section includes all objects, functions, and variables related to game play elements exposed by Torque 3D.


Function Documentation

bool addBadWord ( string  badWord  ) 

Add a string to the bad word filter.

The bad word filter is a table containing words which will not be displayed in chat windows. Instead, a designated replacement string will be displayed. There are already a number of bad words automatically defined.

Parameters:
badWord Exact text of the word to restrict.
Returns:
True if word was successfully added, false if the word or a subset of it already exists in the table
See also:
filterString()
Example:
// In this game, "Foobar" is banned
%badWord = "Foobar";

// Returns true, word was successfully added
addBadWord(%badWord);

// Returns false, word has already been added
addBadWord("Foobar");
bool containerBoxEmpty ( int  mask,
Point3F  center,
float  xRadius,
float  yRadius = -1,
float  zRadius = -1,
bool  useClientContainer = false 
)

See if any objects of the given types are present in box of given extent.

Note:
Extent parameter is last since only one radius is often needed. If one radius is provided, the yRadius and zRadius are assumed to be the same. Unfortunately, if you need to use the client container, you'll need to set all of the radius parameters. Fortunately, this function is mostly used on the server.
Parameters:
mask Indicates the type of objects we are checking against.
center Center of box.
xRadius Search radius in the x-axis. See note above.
yRadius Search radius in the y-axis. See note above.
zRadius Search radius in the z-axis. See note above.
useClientContainer Optionally indicates the search should be within the client container.
Returns:
true if the box is empty, false if any object is found.
string containerFindFirst ( int  mask,
Point3F  point,
float  x,
float  y,
float  z 
)

Find objects matching the bitmask type within a box centered at point, with extents x, y, z.

Returns:
The first object found, or an empty string if nothing was found. Thereafter, you can get more results using containerFindNext().
See also:
containerFindNext
string containerFindNext (  ) 

Get more results from a previous call to containerFindFirst().

Note:
You must call containerFindFirst() to begin the search.
Returns:
The next object found, or an empty string if nothing else was found.
See also:
containerFindFirst()
string containerRayCast ( Point3F  start,
Point3F  end,
int  mask,
SceneObject  pExempt = NULL,
bool  useClientContainer = false 
)

Cast a ray from start to end, checking for collision against items matching mask.

If pExempt is specified, then it is temporarily excluded from collision checks (For instance, you might want to exclude the player if said player was firing a weapon.)

Parameters:
start An XYZ vector containing the tail position of the ray.
end An XYZ vector containing the head position of the ray
mask A bitmask corresponding to the type of objects to check for
pExempt An optional ID for a single object that ignored for this raycast
useClientContainer Optionally indicates the search should be within the client container.
Returns:
A string containing either null, if nothing was struck, or these fields:
  • The ID of the object that was struck.
  • The x, y, z position that it was struck.
  • The x, y, z of the normal of the face that was struck.
  • The distance between the start point and the position we hit.
float containerSearchCurrDist ( bool  useClientContainer = false  ) 

Get distance of the center of the current item from the center of the current initContainerRadiusSearch.

Parameters:
useClientContainer Optionally indicates the search should be within the client container.
Returns:
distance from the center of the current object to the center of the search
See also:
containerSearchNext
float containerSearchCurrRadiusDist ( bool  useClientContainer = false  ) 

Get the distance of the closest point of the current item from the center of the current initContainerRadiusSearch.

Parameters:
useClientContainer Optionally indicates the search should be within the client container.
Returns:
distance from the closest point of the current object to the center of the search
See also:
containerSearchNext
SceneObject containerSearchNext ( bool  useClientContainer = false  ) 

Get next item from a search started with initContainerRadiusSearch() or initContainerTypeSearch().

Parameters:
useClientContainer Optionally indicates the search should be within the client container.
Returns:
the next object found in the search, or null if no more
Example:
// print the names of all nearby ShapeBase derived objects
%position = %obj.getPosition;
%radius = 20;
%mask = $TypeMasks::ShapeBaseObjectType;
initContainerRadiusSearch( %position, %radius, %mask );
while ( (%targetObject = containerSearchNext()) != 0 )
{
   echo( "Found: " @ %targetObject.getName() );
}
See also:
initContainerRadiusSearch()
initContainerTypeSearch()
bool containsBadWords ( string  text  ) 

Checks to see if text is a bad word.

The text is considered to be a bad word if it has been added to the bad word filter.

Parameters:
text Text to scan for bad words
Returns:
True if the text has bad word(s), false if it is clean
See also:
addBadWord()
filterString()
Example:
// In this game, "Foobar" is banned
%badWord = "Foobar";

// Add a banned word to the bad word filter
addBadWord(%badWord);

// Create the base string, can come from anywhere like user chat
%userText = "Foobar";

// Create a string of random letters
%replacementChars = "knqwrtlzs";

// If the text contains a bad word, filter it before printing
// Otherwise print the original text
if(containsBadWords(%userText))
{
   // Filter the string
   %filteredText = filterString(%userText, %replacementChars);

   // Print filtered text
   echo(%filteredText);
}
else
   echo(%userText);
string filterString ( string  baseString = NULL,
string  replacementChars = NULL 
)

Replaces the characters in a string with designated text.

Uses the bad word filter to determine which characters within the string will be replaced.

Parameters:
baseString The original string to filter.
replacementChars A string containing letters you wish to swap in the baseString.
Returns:
The new scrambled string
See also:
addBadWord()
containsBadWords()
Example:
// Create the base string, can come from anywhere
%baseString = "Foobar";

// Create a string of random letters
%replacementChars = "knqwrtlzs";

// Filter the string
%newString = filterString(%baseString, %replacementChars);

// Print the new string to console
echo(%newString);
void initContainerRadiusSearch ( Point3F  pos,
float  radius,
int  mask,
bool  useClientContainer = false 
)

Start a search for items at the given position and within the given radius, filtering by mask.

Parameters:
pos Center position for the search
radius Search radius
mask Bitmask of object types to include in the search
useClientContainer Optionally indicates the search should be within the client container.
See also:
containerSearchNext
void initContainerTypeSearch ( int  mask,
bool  useClientContainer = false 
)

Start a search for all items of the types specified by the bitset mask.

Parameters:
mask Bitmask of object types to include in the search
useClientContainer Optionally indicates the search should be within the client container.
See also:
containerSearchNext
bool isPointInside ( Point3F  position  ) 

Check to see if a point in world space is inside of an interior.

Parameters:
position The position to check in world space.
Example:
// Check to see if a point is inside any interior
%point = "100 100 100";
%isInside = isPointInside(%point);
bool isPointInside ( F32  x,
F32  y,
F32  z 
)

Check to see if a set of coordinates in world space are inside of an interior.

Parameters:
x X-coordinate for position in world space.
y Y-coordinate for position in world space.
z Z-coordinate for position in world space.
Example:
// Check to see if a point is inside any interior
%isInside = isPointInside(100, 100, 100);
void resetFPSTracker (  ) 

Reset FPS stats (fps::).

void sceneDumpZoneStates ( bool  updateFirst = true  ) 

Dump the current zoning states of all zone spaces in the scene to the console.

Parameters:
updateFirst If true, zoning states are brought up to date first; if false, the zoning states are dumped as is.
Note:
Only valid on the client.
SceneObject sceneGetZoneOwner ( int  zoneId = true  ) 

Return the SceneObject that contains the given zone.

Parameters:
zoneId ID of zone.
Returns:
A SceneObject or NULL if the given zoneId is invalid.
Note:
Only valid on the client.
void setInteriorRenderMode ( int  mode  ) 

Globally changes how InteriorInstances are rendered. Useful for debugging geometry and rendering artifacts.

Note:
This does not work in shipping mode
Parameters:
mode The render mode can be one of the following numbers:

NormalRender = 0,

NormalRenderLines = 1,

ShowDetail = 2,

ShowAmbiguous = 3,

ShowOrphan = 4,

ShowLightmaps = 5,

ShowTexturesOnly = 6,

ShowPortalZones = 7,

ShowOutsideVisible = 8,

ShowCollisionFans = 9,

ShowStrips = 10,

ShowNullSurfaces = 11,

ShowLargeTextures = 12,

ShowHullSurfaces = 13,

ShowVehicleHullSurfaces = 14,

ShowVertexColors = 15,

ShowDetailLevel = 16

bool spawnObject ( class  [, dataBlock, name, properties, script]  ) 

Global function used for spawning any type of object.

Note: This is separate from SpawnSphere::spawnObject(). This function is not called off any other class and uses different parameters than the SpawnSphere's function. In the source, SpawnSphere::spawnObject() actually calls this function and passes its properties (spawnClass, spawnDatablock, etc).

Parameters:
class Mandatory field specifying the object class, such as Player or TSStatic.
datablock Field specifying the object's datablock, optional for objects such as TSStatic, mandatory for game objects like Player.
name Optional field specifying a name for this instance of the object.
properties Optional set of parameters applied to the spawn object during creation.
script Optional command(s) to execute when spawning an object.
Example:
// Set the parameters for the spawn function
%objectClass = "Player";
%objectDatablock = "DefaultPlayerData";
%objectName = "PlayerName";
%additionalProperties = "health = \"0\";"; // Note the escape sequence \ in front of quotes
%spawnScript = "echo(\"Player Spawned\");" // Note the escape sequence \ in front of quotes
// Spawn with the engine's Sim::spawnObject() function
%player = spawnObject(%objectClass, %objectDatablock, %objectName, %additionalProperties, %spawnScript);

Variable Documentation

float $cameraFov

The camera's Field of View.

float $mvBackwardAction

Backwards movement speed for the active player.

bool $mvDeviceIsKeyboardMouse

Boolean state for it the system is using a keyboard and mouse or not.

float $mvDownAction

Downwards movement speed for the active player.

float $mvForwardAction

Forwards movement speed for the active player.

bool $mvFreeLook

Boolean state for if freelook is active or not.

float $mvLeftAction

Left movement speed for the active player.

float $mvPitch

Current pitch value, typically applied through input devices, such as a mouse.

float $mvPitchDownSpeed

Downwards pitch speed.

float $mvPitchUpSpeed

Upwards pitch speed.

float $mvRightAction

Right movement speed for the active player.

float $mvRoll

Current roll value, typically applied through input devices, such as a mouse.

float $mvRollLeftSpeed

Left roll speed.

float $mvRollRightSpeed

Right roll speed.

int $mvTriggerCount0

Used to determine the trigger counts of buttons. Namely used for input actions such as jumping and weapons firing.

int $mvTriggerCount1

Used to determine the trigger counts of buttons. Namely used for input actions such as jumping and weapons firing.

int $mvTriggerCount2

Used to determine the trigger counts of buttons. Namely used for input actions such as jumping and weapons firing.

int $mvTriggerCount3

Used to determine the trigger counts of buttons. Namely used for input actions such as jumping and weapons firing.

int $mvTriggerCount4

Used to determine the trigger counts of buttons. Namely used for input actions such as jumping and weapons firing.

int $mvTriggerCount5

Used to determine the trigger counts of buttons. Namely used for input actions such as jumping and weapons firing.

float $mvUpAction

Upwards movement speed for the active player.

float $mvXAxis_L

Left thumbstick X axis position on a dual-analog gamepad.

float $mvXAxis_R

Right thumbstick X axis position on a dual-analog gamepad.

float $mvYaw

Current yaw value, typically applied through input devices, such as a mouse.

float $mvYawLeftSpeed

Left Yaw speed.

float $mvYawRightSpeed

Right Yaw speed.

float $mvYAxis_L

Left thumbstick Y axis position on a dual-analog gamepad.

float $mvYAxis_R

Right thumbstick Y axis position on a dual-analog gamepad.

int $Ease::Back

Backwards ease for curve movement.

int $Ease::Bounce

Bounce ease for curve movement.

int $Ease::Circular

Circular ease for curve movement.

int $Ease::Cubic

Cubic ease for curve movement.

float $pref::Camera::distanceScale

A scale to apply to the normal visible distance, typically used for tuning performance.

int $Ease::Elastic

Elastic ease for curve movement.

bool $pref::enableBadWordFilter

If true, the bad word filter will be enabled.

bool $pref::enablePostEffects

If true, post effects will be eanbled.

int $Ease::Exponential

Exponential ease for curve movement.

int $Ease::In

In ease for curve movement.

int $Ease::InOut

InOut ease for curve movement.

bool $pref::Input::JoystickEnabled

If true, the joystick is currently enabled.

int $Ease::Linear

Linear ease for curve movement.

int $Ease::Out

Out ease for curve movement.

int $Ease::Quadratic

Quadratic ease for curve movement.

int $Ease::Quartic

Quartic ease for curve movement.

int $Ease::Quintic

Quintic ease for curve movement.

int $Ease::Sinusoidal

Sinusoidal ease for curve movement.



Copyright © GarageGames, LLC. All Rights Reserved.