Global functions and variables

These global functions and variables are available in all scripts.


Global functions

Sleep Suspends the script for a specified number of milliseconds
WaitFor Suspends the script until the specified object is "ready"
Random Returns a pseudo-random number from a specified range
SetScriptTimeSlice The script will be automatically suspended after a specified time interval
Debug Pauses game execution and displays a debugging console
MakeRGBA Packs the Red, Green, Blue and Alpha color values into one number
GetRValue Extracts a Red portion of a color
GetGValue Extracts a Green portion of a color
GetBValue Extracts a Blue portion of a color
GetAValue Extracts an Alpha portion of a color
MakeHSL Packs the Hue, Saturation and Luminance color component into one number
GetHValue Extracts a Hue portion of a color
GetSValue Extracts a Saturation portion of a color
GetLValue Extracts a Luminance portion of a color
ToString Converts a specified value to a string
ToInt Converts a specified value to an integer number
ToBool Converts a specified value to a boolean (logical) value
ToFloat Converts a specified value to a floating point number

Global variables

Game (read only) The one and only game object reference

Sleep (Milliseconds)

Suspends the script for a specified number of milliseconds

Parameters

Milliseconds
Number of milliseconds to suspend the script for

Remarks

The Sleep function suspends the script and returns control back to the engine. If you have a script that runs for a very long time, you should periodically call the Sleep function, otherwise the game will seem to be "stuck" until the script finishes.


WaitFor (Object)

Suspends the script until the specified object is "ready"

Parameters

Object
The object to wait for

Remarks

The object is "ready", when it doesn't perform any action (like talking, walking etc.).


Random (From, To)

Returns a pseudo-random number from a specified range

Parameters

From
The lower bound of the range
To
The higher bound of the range

SetScriptTimeSlice (Milliseconds)

The script will be automatically suspended after a specified time interval

Parameters

Milliseconds
The time interval after which the script will be suspended

Remarks

If you have a script that runs for a very long time, you should return control to the engine from time to time. You can do it either manually by calling the Sleep function, or you can set the time-slice interval. In that case, the engine will suspend the script automatically, perform other tasks, and return to the script again.


Debug ()

Pauses game execution and displays a debugging console

Remarks

If debugging console isn't enabled, this function is ignored.


MakeRGBA (R, G, B, A)

Packs the Red, Green, Blue and Alpha color values into one number

Parameters

R
The Red component of the requested color
G
The Green component of the requested color
B
The Blue component of the requested color
A
The Alpha component of the requested color (optional, defaults to 255)

Return value

Returns a color value based on the specified color components

Remarks

All the color components range from 0 to 255. The alpha component specifies the transparency of the resulting color. It ranges from 0 (completely transparent) to 255 (opaque).


GetRValue (Color)

Extracts a Red portion of a color

Parameters

Color
A packed RGBA color

GetGValue (Color)

Extracts a Green portion of a color

Parameters

Color
A packed RGBA color

GetBValue (Color)

Extracts a Blue portion of a color

Parameters

Color
A packed RGBA color

GetAValue (Color)

Extracts an Alpha portion of a color

Parameters

Color
A packed RGBA color

MakeHSL(H, S, L)

Packs the Hue, Saturation and Luminance color component into one number

Parameters

H
The Hue component of the requested color
S
The Saturation component of the requested color
L
The Luminance component of the requested color

Return value

Returns a color value based on the specified color components

Remarks

All the color components range from 0 to 255.


GetHValue(Color)

Extracts a Hue portion of a color

Parameters

Color
A packed color value

GetSValue(Color)

Extracts a Saturation portion of a color

Parameters

Color
A packed color value

GetLValue(Color)

Extracts a Luminance portion of a color

Parameters

Color
A packed color value

ToString (Value)

Converts a specified value to a string

Parameters

Value
The value to be converted

ToInt (Value)

Converts a specified value to an integer number

Parameters

Value
The value to be converted

ToBool (Value)

Converts a specified value to a boolean (logical) value

Parameters

Value
The value to be converted

ToFloat (Value)

Converts a specified value to a floating point number

Parameters

Value
The value to be converted