37 lines
1.5 KiB
Markdown
37 lines
1.5 KiB
Markdown
|
|
# BlockLua
|
|
## How to Install
|
|
- Install RedBlocklandLoader
|
|
- Copy `BlockLua.dll` and `lua5.1.dll` into the `modules` folder next to `Blockland.exe`
|
|
- Optional: Copy the `lualib` folder into `modules`
|
|
|
|
|
|
## Quick Reference
|
|
|
|
### From TorqueScript
|
|
`'print('hello world')` - Execute Lua code in the console by prepending a `'` (single quote)
|
|
`luaeval("code");` - Eval Lua code from Torque
|
|
`luacall("funcName", %args);` - Eval Lua code from Torque
|
|
`luaexec("fileName");` - Execute a Lua file from Torque
|
|
`luaget("varName");` - Read a Lua global variable
|
|
`luaset("varName");` - Write a Lua global variable
|
|
|
|
### From Lua
|
|
`bl.funcName(args)` - Call a TorqueScript function
|
|
`bl.varName` - Read a TorqueScript global variable
|
|
`bl['varName']` - Read a TorqueScript global variable (with special characters in the name, or from an array)
|
|
`bl.set('varName', value)` - Write a TorqueScript global variable
|
|
|
|
### Accessing Torque Objects from Lua
|
|
`bl.objectName` - Access a Torque object by name
|
|
`bl[objectID]` - Access a Torque object by ID (or name)
|
|
`bl.objectName.field` - Read a field or Lua key from a Torque object
|
|
`bl.objectName:set('field', value)` - Write a field on a Torque object
|
|
`bl.objectName.key = value` - Associate Lua data with a Torque object
|
|
`bl.objectName:method(args)` - Call a Torque object method
|
|
|
|
|
|
### Unsafe Mode
|
|
BlockLua-Unsafe.dll can be used in place of BlockLua.dll, to remove the sandboxing of Lua code.
|
|
This allows Lua code to access any file and use any library, including ffi.
|