Novelty scripting reference > Global functions

Global script functions

These are global functions that can be called from anywhere in a script.

GetMousePosition
GetObject
HideCursor
KeyName
PlayBGM
PlaySound
PlayVideo
Print
SeekVideo
StopBGM
StopAllSounds
StopVideo
UserInput


Vector2 GetMousePosition()
Returns the current mouse position (relative to window).


Object@ GetObject(const string in& name)
Object@ GetObject(UID uniqueID)
Get handle to an object by name or UID in the current scene; or null.
The UID version of this function is more efficient.


void HideCursor(bool hide)
Hide the mouse cursor.


string KeyName(KeyCode key)
Returns the english name of a keyboard key.

See also:
OnKeyDown, OnKeyUp


bool PlayBGM(const string in& assetName)
bool PlayBGM(const string in& assetName, float volume, float balance, bool loop)

Plays an audio asset as background music.
Returns true if successful.

Remarks:
Only one BGM track may play at any moment. If a BGM is already playing this will fade in and replace it.
Audio asset must be an available resource - meaning it either has to be used elsewhere in the game or be explicitly added to the project resources.


bool PlaySound(const string in& assetName)
bool PlaySound(const string in& assetName, float volume, float balance)
Plays sound effect.
AssetName must be a name of an asset that has been added to the project.
Returns true if successful.

Remarks:
Audio asset must be an available resource - meaning it either has to be used elsewhere in the game or be explicitly added to the project resources.


bool PlayVideo(uint channel, const string in& filename)
bool PlayVideo(uint channel, const string in& filename, float volume, bool loop)
Loads and plays video in a channel. Channel must be either 1, 2 or 3. Volume is between 0 to 1.
Returns true if successful.


bool SeekVideo(uint channel, double positionInSeconds)

Seeks to a position (in seconds) in a playing video. Channel must be 1, 2 or 3.
Returns true if the video started successful.


void Print(const string in& message)
Print a message in the console window.


void StopBGM()
void StopBGM(float timeInSeconds)

Stop playing current BGM.


void StopAllSounds()
Stops any currently playing sound effects.


void StopVideo()
void StopVideo(uint channel)

Stops a video playing in one or all channels. Channel must be 1, 2 or 3.


string UserInput(const string in& message)
string UserInput(const string in& message, const string in& defaultValue,
    uint maxLength, bool allowEmpty)

Displays a user input dialog. Returns the entered text.


Color ColorFromHSL(double hue, double saturation, double lightness)
Calculates a color from hue, saturation and lightness values. (0.0 to 1.0)


Back to top