Game

Functions

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

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, float zRadius, bool useClientContainer)

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

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:.
string containerFindNext()

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

Returns:The next object found, or an empty string if nothing else was found.
string containerRayCast(Point3F start, Point3F end, int mask, SceneObject pExempt, bool useClientContainer)

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:

The distance between the start point and the position we hit.

float containerSearchCurrDist(bool useClientContainer)

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
float containerSearchCurrRadiusDist(bool useClientContainer)

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
SceneObject containerSearchNext(bool useClientContainer)

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

Example:

// In this game, "Foobar" is banned
%badWord = "Foobar";

// Add a banned word to the bad word filteraddBadWord(%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);
}
elseecho(%userText);
string filterString(string baseString, string replacementChars)

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

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 consoleecho(%newString);
String getOVRHMDChromaticAbCorrection(int index)

Provides the OVR HMD chromatic aberration correction values.

Parameters:index – The HMD index.
Returns:A four component string with the chromatic aberration correction values.
int getOVRHMDCount()

Get the number of HMD devices that are currently connected.

Returns:The number of Oculus VR HMD devices that are currently connected.
float getOVRHMDCurrentIPD(int index)

Physical distance between the user’s eye centers.

Parameters:index – The HMD index.
Returns:The current IPD.
Point2I getOVRHMDDisplayDesktopPos(int index)

Desktop coordinate position of the screen (can be negative; may not be present on all platforms).

Parameters:index – The HMD index.
Returns:Position of the screen.
int getOVRHMDDisplayDeviceId(int index)

MacOS display ID.

Parameters:index – The HMD index.
Returns:The ID of the HMD display device, if any.
string getOVRHMDDisplayDeviceName(int index)

Windows display device name used in EnumDisplaySettings/CreateDC.

Parameters:index – The HMD index.
Returns:The name of the HMD display device, if any.
String getOVRHMDDistortionCoefficients(int index)

Provides the OVR HMD distortion coefficients.

Parameters:index – The HMD index.
Returns:A four component string with the distortion coefficients.
float getOVRHMDDistortionScale(int index)

Provides the OVR HMD calculated distortion scale.

Parameters:index – The HMD index.
Returns:The calculated distortion scale.
Point2F getOVRHMDEyeXOffsets(int index)

Provides the OVR HMD eye x offsets in uv coordinates.

Parameters:index – The HMD index.
Returns:A two component string with the left and right eye x offsets.
string getOVRHMDManufacturer(int index)

Retrieves the HMD manufacturer name.

Parameters:index – The HMD index.
Returns:The manufacturer of the HMD product.
string getOVRHMDProductName(int index)

Retrieves the HMD product name.

Parameters:index – The HMD index.
Returns:The name of the HMD product.
float getOVRHMDProfileIPD(int index)

Physical distance between the user’s eye centers as defined by the current profile.

Parameters:index – The HMD index.
Returns:The profile IPD.
Point2I getOVRHMDResolution(int index)

Provides the OVR HMD screen resolution.

Parameters:index – The HMD index.
Returns:A two component string with the screen’s resolution.
int getOVRHMDVersion(int index)

Retrieves the HMD version number.

Parameters:index – The HMD index.
Returns:The version number of the HMD product.
float getOVRHMDXCenterOffset(int index)

Provides the OVR HMD calculated XCenterOffset.

Parameters:index – The HMD index.
Returns:The calculated XCenterOffset.
float getOVRHMDYFOV(int index)

Provides the OVR HMD calculated Y FOV.

Parameters:index – The HMD index.
Returns:The calculated Y FOV.
Point3F getOVRSensorAcceleration(int index)

Get the acceleration values for the given sensor index.

Parameters:index – The sensor index.
Returns:The acceleration values of the Oculus VR sensor, in m/s^2.
Point3F getOVRSensorAngVelocity(int index)

Get the angular velocity values for the given sensor index.

Parameters:index – The sensor index.
Returns:The angular velocity values of the Oculus VR sensor, in degrees/s.
int getOVRSensorCount()

Get the number of sensor devices that are currently connected.

Returns:The number of Oculus VR sensor devices that are currently connected.
Point3F getOVRSensorEulerRotation(int index)

Get the Euler rotation values for the given sensor index.

Parameters:index – The sensor index.
Returns:The Euler rotation values of the Oculus VR sensor, in degrees.
bool getOVRSensorGravityCorrection(int index)

Get the gravity correction state for the given sensor index.

Parameters:index – The sensor index.
Returns:True if gravity correction (for pitch and roll) is active.
Point3F getOVRSensorMagnetometer(int index)

Get the magnetometer reading (direction and field strength) for the given sensor index.

Parameters:index – The sensor index.
Returns:The magnetometer reading (direction and field strength) of the Oculus VR sensor, in Gauss.
bool getOVRSensorMagnetometerCalibrated(int index)

Get the magnetometer calibrated data state for the given sensor index.

Parameters:index – The sensor index.
Returns:True if magnetometer calibration data is available.
float getOVRSensorPredictionTime(int index)

Get the prediction time set for the given sensor index.

Parameters:index – The sensor index.
Returns:The prediction time of the Oculus VR sensor, given in seconds.
bool getOVRSensorYawCorrection(int index)

Get the yaw correction state for the given sensor index.

Parameters:index – The sensor index.
Returns:True if yaw correction (using magnetometer calibration data) is active.
Point3F getRazerHydraControllerPos(int controller)

Get the given Razer Hydra controller’s last position.

Parameters:controller – Controller number to check.
Returns:A Point3F containing the last known position.
AngAxisF getRazerHydraControllerRot(int controller)

Get the given Razer Hydra controller’s last rotation.

Parameters:controller – Controller number to check.
Returns:A AngAxisF containing the last known rotation.
TransformF getRazerHydraControllerTransform(int controller)

Get the given Razer Hydra controller’s last transform.

Parameters:controller – Controller number to check.
Returns:A TransformF containing the last known transform.
void initContainerRadiusSearch(Point3F pos, float radius, int mask, bool useClientContainer)

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.
void initContainerTypeSearch(int mask, bool useClientContainer)

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.
bool isLeapMotionActive()

Used to determine if the Leap Motion input device is active. The Leap Motion input device is considered active when the support library has been loaded and the device has been found.

Returns:True if the Leap Motion input device is active.
bool isOculusVRDeviceActive()

Used to determine if the Oculus VR input device is active. The Oculus VR device is considered active when the library has been initialized and either a real of simulated HMD is present.

Returns:True if the Oculus VR input device is active.
bool isOVRHMDSimulated(int index)

Determines if the requested OVR HMD is simulated or real.

Parameters:index – The HMD index.
Returns:True if the HMD is simulated.
bool isRazerHydraActive()

Used to determine if the Razer Hydra input device active. The Razer Hydra input device is considered active when the support library has been loaded and the controller has been found.

Returns:True if the Razer Hydra input device is active.
bool isRazerHydraControllerDocked(int controller)

Used to determine if the given Razer Hydra controller is docked.

Parameters:controller – Controller number to check.
Returns:True if the given Razer Hydra controller is docked. Also returns true if the input device is not found or active.
void ovrResetAllSensors()

Resets all Oculus VR sensors. This resets all sensor orientations such that their ‘normal’ rotation is defined when this function is called. This defines an HMD’s forwards and up direction, for example.

void resetFPSTracker()

Reset FPS stats (fps::).

void sceneDumpZoneStates(bool updateFirst)

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.
SceneObject sceneGetZoneOwner(int zoneId)

Return the SceneObject that contains the given zone.

Parameters:zoneId – ID of zone.
Returns:is invalid.
void setAllSensorPredictionTime(float dt)

Set the prediction time set for all sensors.

Parameters:dt – The prediction time to set given in seconds. Setting to 0 disables prediction.
bool setOVRHMDAsGameConnectionDisplayDevice(GameConnection conn)

Sets the first HMD to be a GameConnection’s display device.

Parameters:conn – The GameConnection to set.
Returns:display device was set.
void setOVRHMDCurrentIPD(int index, float ipd)

Set the physical distance between the user’s eye centers.

Parameters:
  • index – The HMD index.
  • ipd – The IPD to use.
void setOVRSensorGravityCorrection(int index, bool state)

Set the gravity correction state for the given sensor index.

Parameters:
  • index – The sensor index.
  • state – The gravity correction state to change to.
void setOVRSensorYawCorrection(int index, bool state)

Set the yaw correction state for the given sensor index.

Parameters:
  • index – The sensor index.
  • state – The yaw correction state to change to.
void setSensorPredictionTime(int index, float dt)

Set the prediction time set for the given sensor index.

Parameters:
  • index – The sensor index.
  • dt – The prediction time to set given in seconds. Setting to 0 disables prediction.
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 engines Sim::spawnObject() function
%player = spawnObject(%objectClass, %objectDatablock, %objectName, %additionalProperties, %spawnScript);

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.

bool $RazerHydra::CombinedPositionEvents

If true, one position event will be sent that includes one component per argument.

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::LeapMotion::EnableDevice

If true, the Leap Motion device will be enabled, if present.

bool $pref::OculusVR::EnableDevice

If true, the Oculus VR device will be enabled, if present.

bool $pref::RazerHydra::EnableDevice

If true, the Razer Hydra device will be enabled, if present.

bool $pref::enablePostEffects

If true, post effects will be eanbled.

int $Ease::Exponential

Exponential ease for curve movement.

bool $OculusVR::GenerateAngleAxisRotationEvents

If true, broadcast sensor rotation events as angled axis.

bool $OculusVR::GenerateEulerRotationEvents

If true, broadcast sensor rotation events as Euler angles about the X, Y and Z axis.

bool $LeapMotion::GenerateIndividualEvents

Indicates that events for each hand and pointable will be created.

bool $OculusVR::GenerateRotationAsAxisEvents

If true, broadcast sensor rotation as axis events.

bool $OculusVR::GenerateSensorRawEvents

If ture, broadcast sensor raw data: acceleration, angular velocity, magnetometer reading.

bool $LeapMotion::GenerateSingleHandRotationAsAxisEvents

If true, broadcast single hand rotation as axis events.

bool $LeapMotion::GenerateWholeFrameEvents

Indicates that a whole frame event should be generated and frames should be buffered.

bool $OculusVR::GenerateWholeFrameEvents

Indicates that a whole frame event should be generated and frames should be buffered.

bool $RazerHydra::GenerateWholeFrameEvents

Indicates that a whole frame event should be generated and frames should be buffered.

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.

bool $LeapMotion::KeepHandIndexPersistent

Indicates that we track hand IDs and will ensure that the same hand will remain at the same index between frames.

bool $LeapMotion::KeepPointableIndexPersistent

Indicates that we track pointable IDs and will ensure that the same pointable will remain at the same index between frames.

int $Ease::Linear

Linear ease for curve movement.

float $OculusVR::MaximumAxisAngle

The maximum sensor angle when used as an axis event as measured from a vector pointing straight up (in degrees). Should range from 0 to 90 degrees.

float $RazerHydra::MaximumAxisAngle

The maximum controller angle when used as an axis event as measured from a vector pointing straight up (in degrees). Shoud range from 0 to 90 degrees.

int $LeapMotion::MaximumFramesStored

The maximum number of frames to keep when $LeapMotion::GenerateWholeFrameEvents is true.

int $RazerHydra::MaximumFramesStored

The maximum number of frames to keep when $RazerHydra::GenerateWholeFrameEvents is true.

float $LeapMotion::MaximumHandAxisAngle

The maximum hand angle when used as an axis event as measured from a vector pointing straight up (in degrees). Shoud range from 0 to 90 degrees.

int $Ease::Out

Out ease for curve movement.

bool $RazerHydra::ProcessWhenDocked

If true, events will still be sent when a controller is docked.

int $Ease::Quadratic

Quadratic ease for curve movement.

int $Ease::Quartic

Quartic ease for curve movement.

int $Ease::Quintic

Quintic ease for curve movement.

bool $RazerHydra::RotationAsAxisEvents

If true, broadcast controller rotation as axis events.

bool $RazerHydra::SeparatePositionEvents

If true, separate position events will be sent for each component.

int $Ease::Sinusoidal

Sinusoidal ease for curve movement.

bool $pref::OculusVR::UseChromaticAberrationCorrection

If true, Use the chromatic aberration correction version of the Oculus VR barrel distortion shader.