Threads

Regular thread

A thread block creates a temporary script that runs alongside the current script, copying the current script variables to the new script

thread {
    // do stuff
}

Child thread

Similar to a regular thread except the thread is killed when the current script is finished executing

cthread {
    // do stuff
}

Exec/Exec Wait

The family of exec functions allow for launching a new script from inside another

The exec function launches a script without blocking the execution of the current script

exec(cool_script)

The id of the launched script can be stored in a variable

Var[0] = exec(cool_script)

The exec_wait function launches a script and blocks the execution of the current script until the child returns

exec_wait(cool_script)

Misc functions

FunctionArgumentsReturn valueDescription
bindscript pointer, event type: int, collider id: inttrigger pointerbinds a script to run when an event is triggered
bind_lockscript pointer, event type: int, collider id: int, item list: inttrigger pointerworks similar to the bind function but displays a list showing selectable items
unbind--unbinds the current script from a trigger
killid: int-kills a script with the given id
set_prioritypriority: int-sets the priority of a script
set_timescaletimescale: float-sets the timescale of a script
set_groupgroup: int-sets the group of a script
suspend_groupgroup: int-suspends all scripts in the given group
resume_groupgroup: int-resumes all scripts in the given group
suspend_othersgroup: int-suspends all scripts in the given group excluding the current script
resume_othersgroup: int-resumes all scripts in the given group excluding the current script
suspend_threadid: int-suspends all scripts with the id as well as their children
resume threadid: int-resumes all scripts with the id as well as their children
is_thread_runningid: intboolreturns whether a script with the given id is in the current script list