run_lua
Execute Lua in Tabletop Simulator's global script context to manipulate game objects and return results as JSON-compatible values. Use return statements; userdata must be returned as fields.
Instructions
Execute Lua in the TTSim Global script context and return the result.
Use return to get a value back. Tables arrive as JSON objects/arrays; numbers, strings,
booleans and nil (null) work too. TTSim objects (userdata) cannot be returned directly:
return their fields instead, e.g. local o = getObjectFromGUID("abc123") return {name = o.getName(), pos = o.getPosition()}.
Lua runtime and syntax errors come back as tool errors with the TTSim message.
Changes made here are visible to the player immediately, so act deliberately.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "run_lua"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes |