execute_script
Run multi-line GDScript code in the current scene's context at runtime, with support for variables, loops, and control flow for complex logic.
Instructions
Execute a multi-line GDScript block at runtime in the current scene context. Unlike evaluate_expression, supports variables, loops, and control flow. Requires run_interactive.
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": "execute_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The GDScript code to execute. Runs as a function body in the context of the current scene. Use "return x" to return a value. Example: "var p = $Player\nreturn p.position" |