Skip to content

Script

Reference for the script API.

Functions

script.running

If a script is running.

lua
---@param name string|integer
function script.running(name): bool

script.globals

Creates an instance of script_global.

lua
---@param base integer
function script.globals(base): script_global

script.tunables

Creates an instance of tunables.

lua
---@param name string|integer
function script.tunables(name): tunables

script.locals

Creates an instance of script_local.

lua
---@param name string|integer
---@param base integer
function script.locals(name, base): script_local

script.program

Script program memory address retrieved via the script name.

lua
---@param name string|integer
function script.program(name): memory_address

script.host

Returns a player for the host of the given script.

lua
---@param name string
function script.host(name): player

script.force_host

Force host of a script.

lua
---@param script string|integer
function script.force_host(script): bool

script.call

Calls a script function via its function offset.

lua
---@param name string|integer
---@param position integer
---@param args table
function script.call(name, position, args): memory_address

script.patch

Creates a script patch.

lua
---@param name string|integer
---@param position integer
---@param offset integer
---@param bytes integer[]
function script.patch(name, position, offset, bytes): script_patch

script.execute_as

Run a callback as a script.

lua
---@param name string|integer
---@param callback function
function script.execute_as(name, callback): nil

Types

script_global

FieldType
addressmemory_address
vec2vec2
vec3scr_vec3
int8integer
int16integer
int32integer
int64integer
uint8integer
uint16integer
uint32integer
uint64integer
floatnumber
doublenumber
boolbool
strstring
lua
---@param index integer
function script_global:at(index): script_global

---@param index integer
---@param size integer
function script_global:at(index, size): script_global

script_local

FieldType
addressmemory_address
vec2vec2
vec3scr_vec3
int8integer
int16integer
int32integer
int64integer
uint8integer
uint16integer
uint32integer
uint64integer
floatnumber
doublenumber
boolbool
strstring
lua
---@param index integer
function script_local:at(index): script_local

---@param index integer
---@param size integer
function script_local:at(index, size): script_local

script_patch

FieldType
enabledbool
originalinteger[]
patchinteger[]
lua
function script_patch:enable(): nil
function script_patch:disable(): nil

tunables

FieldType
int8integer
int16integer
int32integer
int64integer
uint8integer
uint16integer
uint32integer
uint64integer
floatnumber
doublenumber
boolbool

Examples

lua
function get_owned_property(index, character)
  local result = script.call('freemode', 0xAA7B7, {index, character})
  return result and result.int32 or 0
end

script.globals(2672741):at(3694).bool = true
script.locals('am_mp_drone', 197):at(245).int32 = 0