TorqueScript Reference
Functions
Math (Non-Vector)

Functions

Integer addBitToMask (mask, bit)
 
String bit ()
 
String bitInverse ()
 
String bits ()
 
Float mAbs (val)
 
Float mAcos (val)
 
Float mAsin (val)
 
Float mAtan (val)
 
Integer mCeil (val)
 
Float mClamp (float number, float min, float max)
 
Float mCos (val)
 
Float mDegToRad (val)
 
Float mEase (easeFunction, progress)
 
String mFloatLength (val, numDecimals)
 
Integer mFloor (val)
 
Float mGetMax (a, b)
 
Float mGetMin (a, b)
 
Float mLog (val)
 
Float mPow (val, power)
 
Float mRadToDeg (val)
 
Float mRound (float v)
 
Float mSin (val)
 
String mSolveCubic (float a, float b, float c, float d)
 
String mSolveQuadratic (float a, float b, float c)
 
String mSolveQuartic (float a, float b, float c, float d, float e)
 
Float mSqrt (val)
 
Float mTan (val)
 
Integer removeBitFromMask (mask, bit)
 

Detailed Description

Function Documentation

◆ addBitToMask()

Integer addBitToMask ( mask  ,
bit   
)

Returns the mask with a bit added to it

◆ bit()

String bit ( )

Converts a bit-position into a value.

◆ bitInverse()

String bitInverse ( )

Returns the ones complement of a bit.

◆ bits()

String bits ( )

Converts a list of bit-positions into a value.

◆ mAbs()

Float mAbs ( val  )

Use the mAbs function to get the magnitude of val.

Parameters
valAn integer or a floating-point value.
Returns
Returns the magnitude of val

◆ mAcos()

Float mAcos ( val  )

Use the mAcos function to get the inverse cosine of val in degrees.

Parameters
valA value between -1.0 and 1.0 equal to the cosine of some angle theta.
Returns
Returns the inverse cosine of val in radians. This value will be in the range [ 0 , 180 ].
See also
mCos

◆ mAsin()

Float mAsin ( val  )

Use the mAsin function to get the inverse sine of val in degrees.

Parameters
valA value between -1.0 and 1.0 equal to the sine of some angle theta.
Returns
Returns the inverse sine of val in degrees. This value will be in the range [ -90, 90 ].
See also
mSin

◆ mAtan()

Float mAtan ( val  )

Use the mAtan function to get the inverse tangent of rise/run in degrees. May be called as mAtan( deltaX, deltaY ) or mAtan( "deltaX deltaY" ).

Parameters
x-axisrun Horizontal component of a line.
y-axisrise Vertical component of a line.
Returns
Returns the slope in degrees (the arc-tangent) of a line with the given run and rise.
See also
mTan

◆ mCeil()

Integer mCeil ( val  )

Use the mCeil function to calculate the next highest integer value from val.

Parameters
valA floating-point value.
Returns
Returns an integer representing the next highest integer from val.
See also
mFloor

◆ mClamp()

Float mClamp ( float  number,
float  min,
float  max 
)

Clamp a value between two other values.

Parameters
numberA float value representing the number to clamp
minThe lower bound
maxThe upper bound
Returns
A float value the is within the given range

◆ mCos()

Float mCos ( val  )

Use the mCos function to get the cosine of the angle val.

Parameters
valA value in degrees.
Returns
Returns the cosine of val. This value will be in the range [ -1.0 , 1.0 ].
See also
mAcos

◆ mDegToRad()

Float mDegToRad ( val  )

Use the mDegToRad function to convert degrees to radians.

Parameters
valA floating-point number representing some number of degrees.
Returns
Returns the equivalent of the degree value val in radians.
See also
mRadToDeg

◆ mEase()

Float mEase ( easeFunction  ,
progress   
)

Given a linear progress from 0 to 1, the ease function returns an "eased" version of that progress. The returned value might be outside of 0 and 1.

Parameters
easeFunctionThe name of the easing function to use. Possible values include EaseIn, EaseOut, EaseInOut and postfix versions of Back, Elastic, and Bounce (i.e. EaseInBounce).
progressLinear progress from 0 to 1.
Returns
An eased progress from 0 to 1 (although the value might go outside of 0 and 1).

◆ mFloatLength()

String mFloatLength ( val  ,
numDecimals   
)

Use the mFloatLength function to limit the number of decimal places in val to numDecimals.

Parameters
valA floating-point value.
numDecimalsAn integer between 0 and inf representing the number of decimal places to allow val to have.
Returns
Returns a floating-point value equivalent to a truncated version of val, where the new version has numDecimals decimal places

◆ mFloor()

Integer mFloor ( val  )

Use the mFloor function to calculate the next lowest integer value from val.

Parameters
valA floating-point value.
Returns
Returns an integer representing the next lowest integer from val.
See also
mCeil

◆ mGetMax()

Float mGetMax ( ,
 
)

Returns the Maximum of two values.

◆ mGetMin()

Float mGetMin ( ,
 
)

Returns the Minimum of two values.

◆ mLog()

Float mLog ( val  )

Use the mLog function to calculate the natural logarithm of val.

Parameters
valA numeric value.
Returns
Returns the natural logarithm of val

◆ mPow()

Float mPow ( val  ,
power   
)

Use the mPow function to calculated val raised to the power of power.

Parameters
valA numeric (integer or floating-point) value to be raised to a power.
powerA numeric (integer or floating-point) power to raise val to.
Returns
Returns val^power

◆ mRadToDeg()

Float mRadToDeg ( val  )

Use the mRadToDeg function to convert radians to degrees.

Parameters
valA floating-point number representing some number of radians.
Returns
Returns the equivalent of the radian value val in degrees.
See also
mDegToRad

◆ mRound()

Float mRound ( float  v)

Rounds a number. 0.5 is rounded up.

Parameters
valA floating-point value
Returns
Returns the integer value closest to the given float

◆ mSin()

Float mSin ( val  )

Use the mSin function to get the sine of the angle val.

Parameters
valA value in degrees.
Returns
Returns the sine of val. This value will be in the range [ -1.0 , 1.0 ].
See also
mAsin

◆ mSolveCubic()

String mSolveCubic ( float  a,
float  b,
float  c,
float  d 
)

Solve a cubic equation of form a*x^3 + b*x^2 + c*x + d = 0.

Returns
A 4-tuple, contanining: sol x0 x1 x2. sol is the number of solutions (being 0, 1, 2, or 3), and x0, x1, x2 are the solutions, if any. Unused x's are undefined.

◆ mSolveQuadratic()

String mSolveQuadratic ( float  a,
float  b,
float  c 
)

Solve a quadratic equation of form a*x^2 + b*x + c = 0.

Returns
A triple, contanining: sol x0 x1. sol is the number of solutions (being 0, 1, or 2), and x0 and x1 are the solutions, if any. Unused x's are undefined.

◆ mSolveQuartic()

String mSolveQuartic ( float  a,
float  b,
float  c,
float  d,
float  e 
)

Solve a quartic equation of form a*x^4 + b*x^3 + c*x^2 + d*x + e = 0.

Returns
A 5-tuple, contanining: sol x0 x1 x2 x3. sol is the number of solutions (ranging from 0-4), and x0, x1, x2 and x3 are the solutions, if any. Unused x's are undefined.

◆ mSqrt()

Float mSqrt ( val  )

Use the mSqrt function to calculated the square root of val.

Parameters
valA numeric value.
Returns
Returns the the squareroot of val

◆ mTan()

Float mTan ( val  )

Use the mTan function to get the tangent of the angle val.

Parameters
valA value in degrees.
Returns
Returns the tangent of val. This value will be in the range [ -inf.0 , inf.0 ].
See also
mAtan

◆ removeBitFromMask()

Integer removeBitFromMask ( mask  ,
bit   
)

Returns the mask with a bit removed from it