Script Functions

Return to Functions

LoadScript

    Arguments:
        1) string: scriptPath
    Return Type:
        real

Loads and compiles the specified script, and returns its script ID.
Also calls @Loading and initializes global variables in the script.

LoadScriptInThread

    Arguments:
        1) string: scriptPath
    Return Type:
        real

Loads and compiles the specified script in a different thread, and returns its script ID.
Also calls @Loading and initializes global variables in the script.

StartScript

    Arguments:
        1) real: scriptID
    Return Type:
        real

Starts the specified script.
Calls @Initialize and starts @MainLoop in the script.

CloseScript

    Arguments:
        1) real: scriptID

Stops the specified script.

Until this function is called, the script will continue to run.

IsCloseScript

    Arguments:
        1) real: scriptID
    Return Type:
        bool

Returns whether the specified script has been stopped.
Returns true if the script is not running.

SetScriptArgument

    Arguments:
        1) real: scriptID
        2) real: argumentIndex
        3) any: value

Before starting the given script with StartScript, sets a value that is to be passed to the given script upon starting.

This value can be retrieved in the started script with GetScriptArgument.

GetScriptArgument

    Arguments:
        1) real: argumentIndex
    Return Type:
        any

Returns the value of the specified argument, previously set by SetScriptArgument before the script was started.

GetScriptArgumentCount

    Return Type:
        real

Returns the number of arguments set by SetScriptArgument before the script was started.

CloseStgScene

Ends the current scene (returns to script selection screen).

GetOwnScriptID

    Return Type:
        real

Returns the script's own ID.

GetEventType

    Return Type:
        real const

Returns the event type currently triggered in @Event.

GetEventArgument

    Arguments:
        1) real: argumentIndex
    Return Type:
        any

Returns the argument of the event currently triggered in @Event.

Note: Can be an arbitrary value.

SetScriptResult

    Arguments:
        1) any: eventResult

Sets the result of the event in @Event, which can then be retrieved by GetScriptResult.

GetScriptResult

    Arguments:
        1) real: scriptID
    Return Type:
        any

Returns the event result from SetScriptResult.

Note: Can be an arbitrary value.

SetAutoDeleteObject

    Arguments:
        1) bool: enable

Sets whether to delete all existing objects that were created in the current script at its termination.

If set to true, the current script's objects will be deleted.
The default value is false.

NotifyEvent

    Arguments:
        1) real: scriptID
        2) real const: eventType
        3+) any: arguments...

Calls the @Event of the script with the specified ID, triggering the specified event.

An arbitrary amount of arguments may be passed to the event, but there must be at least one.
The event type may use a value greater than EV_USER.

NotifyEventAll

    Arguments:
        1) real const: eventType
        2) any: arguments...

Calls the @Event of all scripts, triggering the specified event in all scripts listening for it.

An arbitrary amount of arguments may be passed to the event, but there must be at least one.
The event type may use a value greater than EV_USER.

GetScriptInfoA1

    Arguments:
        1) string: scriptPath
        1) real const: infoType
    Return Type:
        varies

Parses and returns information from the script file's header.

Constants for infotype are as follows:

INFO_SCRIPT_TYPE: Returns the script type (const): one of TYPE_SCRIPT_PLAYER: Player script, TYPE_SCRIPT_SINGLE: Single script, TYPE_SCRIPT_PLURAL: Plural script, TYPE_SCRIPT_STAGE: Stage script, or TYPE_SCRIPT_PACKAGE: Package script.
INFO_SCRIPT_PATH: Returns the script path (string).
INFO_SCRIPT_ID: Returns the script #ID (int).
INFO_SCRIPT_TITLE: Returns the script #Title (string).
INFO_SCRIPT_TEXT: Returns the script #Text (string).
INFO_SCRIPT_IMAGE: Returns the script #Image (string).
INFO_SCRIPT_REPLAY_NAME: Returns the script #ReplayName (string).

SetScriptDifficulty

    Arguments:
        1) real: difficulty

Sets the difficulty level of all scripts, affecting both currently running scripts and future started ones.

This is used mainly for the difficulty (colon) operator: let value = easyVal: normalVal: hardVal: lunaticVal; and !ENHL statements.
0 = Easy, 1 = Normal, 2 = Hard, 3 = Lunatic, 4 = ArbitraryW, 5 = ArbitraryX, 6 = ArbitraryY, 7 = ArbitraryZ, 8 = ArbitraryO

GetScriptDifficulty

    Return Type:
        real

Gets the difficulty level of all running scripts.