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.

NotifyEventOwn

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

Calls the @Event of the script that called this function, 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
        2) 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).

CompilePackageScriptToFile

    Arguments:
        1) string: pathInput
        2) string: pathOutput
        3) bool: bRemoveDnhDirective = true
    Return Type:
        bool

Compiles the given package script into an executable bytecode file and saves it at the given output path.
If bRemoveDnhDirective is true (default), the #TouhouDanmakufu directive will be removed from the script, causing it to not appear in the RDNH menu.

Returns false on failure and logs an error to the log window, which will look like a normal script error.

Note: Bytecode formats may change between engine versions, so scripts should be freshly compiled whenever a new version is downloaded.

CompileSystemScriptToFile

    Arguments:
        1) string: pathInput
        2) string: pathOutput
        3) bool: bRemoveDnhDirective = true
    Return Type:
        bool

Compiles the given system script into an executable bytecode file and saves it at the given output path.
If bRemoveDnhDirective is true (default), the #TouhouDanmakufu directive will be removed from the script, causing it to not appear in the RDNH menu.

Returns false on failure and logs an error to the log window, which will look like a normal script error.

Note: Bytecode formats may change between engine versions, so scripts should be freshly compiled whenever a new version is downloaded.

CompileStageScriptToFile

    Arguments:
        1) string: pathInput
        2) string: pathOutput
        3) bool: bRemoveDnhDirective = true
    Return Type:
        bool

Compiles the given stage script into an executable bytecode file and saves it at the given output path.
If bRemoveDnhDirective is true (default), the #TouhouDanmakufu directive will be removed from the script, causing it to not appear in the RDNH menu.

Returns false on failure and logs an error to the log window, which will look like a normal script error.

Note: Bytecode formats may change between engine versions, so scripts should be freshly compiled whenever a new version is downloaded.

CompilePlayerScriptToFile

    Arguments:
        1) string: pathInput
        2) string: pathOutput
        3) bool: bRemoveDnhDirective = true
    Return Type:
        bool

Compiles the given player script into an executable bytecode file and saves it at the given output path.
If bRemoveDnhDirective is true (default), the #TouhouDanmakufu directive will be removed from the script, causing it to not appear in the RDNH menu.

Returns false on failure and logs an error to the log window, which will look like a normal script error.

Note: Bytecode formats may change between engine versions, so scripts should be freshly compiled whenever a new version is downloaded.

CompileItemScriptToFile

    Arguments:
        1) string: pathInput
        2) string: pathOutput
        3) bool: bRemoveDnhDirective = true
    Return Type:
        bool

Compiles the given item script into an executable bytecode file and saves it at the given output path.
If bRemoveDnhDirective is true (default), the #TouhouDanmakufu directive will be removed from the script, causing it to not appear in the RDNH menu.

Returns false on failure and logs an error to the log window, which will look like a normal script error.

Note: Bytecode formats may change between engine versions, so scripts should be freshly compiled whenever a new version is downloaded.

CompileShotScriptToFile

    Arguments:
        1) string: pathInput
        2) string: pathOutput
        3) bool: bRemoveDnhDirective = true
    Return Type:
        bool

Compiles the given shot script into an executable bytecode file and saves it at the given output path.
If bRemoveDnhDirective is true (default), the #TouhouDanmakufu directive will be removed from the script, causing it to not appear in the RDNH menu.

Returns false on failure and logs an error to the log window, which will look like a normal script error.

Note: Bytecode formats may change between engine versions, so scripts should be freshly compiled whenever a new version is downloaded.