Libraries.Game.NumberUtilities Documentation

The NumberUtilities class contains some actions used by the game engine to manipulate the bits of a number for graphical purposes. Most users will never need to interface with this class directly.

Inherits from: Libraries.Language.Object

Actions Documentation

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

EncodeColorIntegerAsNumber(integer target)

Creates a number with the same bits as the integer parameter, ensuring that the returned number is a valid color code.

Parameters

  • integer target

Return

number:

EncodeIntegerAsNumber(integer target)

Creates a number with the same bits as the integer parameter.

Parameters

  • integer target

Return

number:

EncodeNumberAsInteger(number target)

Creates an integer with the same bits as the number parameter.

Parameters

  • number target

Return

integer:

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

PackNormalizedVector4(number x, number y, number z, number w)

This action takes 4 ordered number inputs between 0.0 and 1.0 and compresses them into a single number that can be passed into the shader system as an input for a 4-dimensional vector (in GLSL, a "vec4" variable). This action doesn't check the incoming values, and if they don't fall within the allowed range, the result will be abnormal. Users should make sure they only pass values between 0.0 and 1.0 into this action.

Parameters

  • number x: The first value to be stored in the compressed vector.
  • number y: The second value to be stored in the compressed vector.
  • number z: The third value to be stored in the compressed vector.
  • number w: The fourth value to be stored in the compressed vector.

Return

number: