Class

VM

VM() → {VM}

Operate VM module. Responsible for initalizing the VM state and evaluating and executing Lua code in the VM.

Constructor

# new VM() → {VM}

Initliazes a new VM state.

View Source operate/vm.js, line 24

VM

Methods

# call(path, args) → {String|Number|Object|Array|function}

Calls a function within the VM state at the given lua path and returns the result.

Parameters:
Name Type Description
path String | Array

Lua path

args Array

Function arguments

View Source operate/vm.js, line 230

String | Number | Object | Array | function

# eval(code) → {String|Number|Object|Array|function}

Evaluates the given script within the VM state and returns the result.

Parameters:
Name Type Description
code String

Lua code string

View Source operate/vm.js, line 200

String | Number | Object | Array | function

# exec(code) → {VM}

Evaluates the given script within the VM state and returns the modified state.

Parameters:
Name Type Description
code String

Lua code string

View Source operate/vm.js, line 213

VM

# extend(extension) → {VM}

Extends the VM state with the given module or modules.

Parameters:
Name Type Description
extension Extension | Array

Extension class or array

View Source operate/vm.js, line 39

VM

# get(path) → {String|Number|Object|Array|function}

Returns the value from the specified path on the VM state.

Parameters:
Name Type Description
path String | Array

Lua path

View Source operate/vm.js, line 54

String | Number | Object | Array | function

# set(path, value, opts) → {VM}

Sets the value at the specified path on the VM state.

Parameters:
Name Type Description
path String | Array

Lua path

value String | Number | Object | Array

Value

opts Object

Options

View Source operate/vm.js, line 79

VM

# setDeep(path, value) → {VM}

Sets the value at the specified deeply nested path on the VM state.

Parameters:
Name Type Description
path String | Array

Lua path

value String | Number | Object | Array

Value

View Source operate/vm.js, line 129

VM

# setFunction(path, callback, opts) → {VM}

Sets a JavaScript function at the specified path on the VM state. Automatically detects if the function is an AsyncFunction, and if so handles yielding and resuming from Lua.

Parameters:
Name Type Description
path String | Array

Lua path

callback function

JavaScript function

opts Object

Options

View Source operate/vm.js, line 162

VM