APEX docs
Reference

Scripts

Read, run and dump the scripts a game contains.

decompile

Turns a script's bytecode back into readable source. It accepts a script object or raw bytecode.

DecompilerOptions

Also available as DecompilerFormatter DecompilerOptions.new DecompilerFormatter.new

Creates settings for the decompiler. The formatter lets you set indent width and column limit.

dumpstring

Also available as getscriptbytecode dump_string get_script_bytecode

Returns a script's compiled bytecode as a string (getscriptbytecode). Raises an error if it cannot be read.

function getscriptbytecode(script: BaseScript | ModuleScript): string | nil

getcallingscript

Also available as get_calling_script

Returns the script that called the current function, or nil if it was not a script.

function getcallingscript(): BaseScript | ModuleScript | nil

getloadedmodules

Also available as getmodules get_loaded_modules

Returns every ModuleScript that has been loaded.

function getloadedmodules(): { ModuleScript }

getrunningscripts

Also available as get_running_scripts

Returns every script that is running right now.

function getrunningscripts(): { BaseScript | ModuleScript }

getscriptclosure

Also available as getscriptfunction get_script_closure get_script_function

Compiles a script's bytecode and returns it as a new function, without running the original script.

function getscriptclosure(script: BaseScript | ModuleScript): (...any) -> (...any) | nil

getscriptfromthread

Also available as get_script_from_thread

Returns the script a given thread belongs to, or nil.

function getscriptfromthread(thread: thread): BaseScript | ModuleScript | nil

getscripthash

Also available as get_script_hash

Returns a hash of a script's source, so you can tell when it changes.

function getscripthash(script: BaseScript | ModuleScript): string | nil

getscripts

Also available as get_scripts

Returns every script and module in the game.

function getscripts(): { BaseScript | ModuleScript }

getscriptthread

Also available as get_script_thread

Returns the thread a running script is executing on.

getsenv

Also available as get_senv

Returns the environment of a running script, which gives access to its local functions and variables.

function getsenv(script: BaseScript | ModuleScript): { [any]: any } | nil