Scaleform Studio Lua API Reference: bit namespace reference

bit namespace reference

Description

Provided for bitwise manipulations.

Functions

Parameters

x :

number

The number to shift.

n :

integer

The number of bits.

Returns

number

The right shifted number.

This function returns the number x shifted n bits to the right. Negative displacements shift to the left.

Parameters

args :

any*

The arguments to "and".

The * notation indicates that there may be zero or more instances of the specified type.
Returns

number

The resultant number.

Parameters

x :

number

The number to negate.

Returns

number

The resultant number.

Parameters

args :

any*

The arguments to "or".

The * notation indicates that there may be zero or more instances of the specified type.
Returns

number

The resultant number.

Parameters

x :

number

The number to convert.

Returns

number

The swapped number.

Can be used to convert little-endian 32 bit numbers to big-endian 32 bit numbers or vice versa.

Parameters

x :

number

The number to convert.

Returns

number

The swapped number.

Parameters

args :

any*

The operands to "and".

The * notation indicates that there may be zero or more instances of the specified type.
Returns

boolean

A boolean signaling whether the bitwise and of its operands is different from zero

Parameters

args :

any*

The operands to "or".

The * notation indicates that there may be zero or more instances of the specified type.
Returns

number

The resultant number.

Parameters

x :

number

The number to shift.

n :

integer

The displacement bit.

Returns

number

The left shifted number.

This function returns the number x shifted n bits to the left. Negative displacements shift to the right.

Parameters

x :

number

The number to rotate

n :

number

The number of bits.

Returns

number

The resultant number.

Parameters

x :

number

The number to rotate.

n :

number

The number of bits.

Returns

number

The resultant number.

Parameters

x :

number

The number to shift.

n :

integer

The number of bits to displace.

Returns

number

The right shifted number.

This function returns the number x shifted n bits to the right.

Parameters

x :

number

The number to convert.

Returns

number

The resultant number.

Parameters

x :

number

The number to convert.

n :

number?

Indicates the number of hex digits.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns

number

The hex string.

The number of hex digits is given by the absolute value of the optional second argument. Positive numbers between 1 and 8 generate lowercase hex digits. Negative numbers generate uppercase hex digits. The default is to generate 8 lowercase hex digits.

 bit.arshift (x, n) : number
Shifts the number to the right (arithmetic right shift).
 x : number
The number to shift.
 n : integer
The number of bits.
 number
The right shifted number.
A numeric value.A strictly integral numeric value, with no decimal component.  bit.band (args) : number
Performes bitwise and on the arguments passed.
 args : any*
The arguments to "and".
The * notation indicates that there may be zero or more instances of the specified type.
 number
The resultant number.
This value may be an instance of any type.  bit.bnot (x) : number
Performes bitwise negation of the number.
 x : number
The number to negate.
 number
The resultant number.
 bit.bor (args) : number
Performes bitwise or on the arguments passed.
 args : any*
The arguments to "or".
The * notation indicates that there may be zero or more instances of the specified type.
 number
The resultant number.
 bit.bswap (x) : number
Swaps the bytes of the passed argument and returns it.
 x : number
The number to convert.
 number
The swapped number.
 x : number
The number to convert.
 number
The swapped number.
 bit.btest (args) : boolean
Returns a boolean signaling whether the bitwise and of its operands is different from zero.
 args : any*
The operands to "and".
The * notation indicates that there may be zero or more instances of the specified type.
 booleantrue or false.  bit.bxor (args) : number
Performes bitwise exclusive or of its operands.
 args : any*
The operands to "or".
The * notation indicates that there may be zero or more instances of the specified type.
 number
The resultant number.
 bit.lshift (x, n) : number
Shifts the number to the left (logical left shift).
 x : number
The number to shift.
 n : integer
The displacement bit.
 number
The left shifted number.
 bit.rol (x, n) : number
Returns the number x rotated n bits to the left (bitwise left rotation).
 x : number
The number to rotate
 n : number
The number of bits.
 number
The resultant number.
 bit.ror (x, n) : number
Returns the number x rotated n bits to the right (bitwise right rotation).
 x : number
The number to rotate.
 n : number
The number of bits.
 number
The resultant number.
 bit.rshift (x, n) : number
Shifts the number to the right (logical right shift).
 x : number
The number to shift.
 n : integer
The number of bits to displace.
 number
The right shifted number.
 bit.tobit (x) : number
Normalizes a number to the numeric range for bit operations and returns it.
 x : number
The number to convert.
 number
The resultant number.
 bit.tohex (x, n) : number
Converts the first argument to a hex string.
 x : number
The number to convert.
 n : number?
Indicates the number of hex digits.
The ? notation indicates that this type is optional: there may be zero or one instances of it.
 number
The hex string.
Indicates a table.
This documentation uses the term table to mean an anonymous, temporary Lua table that contains named data values. You typically use these tables to pass data or settings to a function, or to hold data returned by a function.
Indicates an object.
This documentation uses the term object to mean a named Lua table or userdata value that maintains a state. Some object types may have multiple instances existing at the same time, each with its own state; these objects typically have creation functions or accessors that you must call in order to get an instance. Some object types have only one instance, which you always access through the object's name.
Indicates a named variable within a namespace, object or table; or an element within an enumeration.Indicates a code sample.Indicates an enumeration.
This documentation uses the term enumeration to mean a named Lua table that contains only a set of constant values. These values typically identify a predefined set of options for some setting or behavior. You might pass an enumeration value to a function, or test the value returned by a function against the items in the enumeration to see which option is currently set.
Indicates a named variable within a namespace or object that has a pre-set constant value.Indicates a category: a semantic grouping of related API elements.Indicates a namespace.
This documentation uses the term namespace to mean a named Lua table that exists in only one single instance, intended as a container for an interface of related objects, functions and data variables.
Indicates an output value returned by a function.Indicates a named function within a namespace or object.Indicates an input parameter for a function.