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.
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" |