Script / Execute
script-executeCompile and run C# code or a class method directly in the Godot editor, returning the result and printed output. Timeouts stop endless loops while the process keeps running.
Instructions
Compiles and runs C# in the Godot editor: plain statements with the last expression as the result (own usings, local classes, await allowed), or a declared class 'className' with static method 'methodName'. Returns the result and the printed output (Console; GD.Print on Godot 4.5+). Guarded: an endless loop is stopped when its time budget ('timeout', default 30 s) runs out, and runaway recursion is stopped, with an error, and the process keeps running. Threads and tasks the code starts (new Thread, Task.Run, ThreadPool) are stopped at their next loop iteration or call once the run ends (a warning counts them); timers, async void code after its first await and work blocked in a wait are not, so join or await what you start.
Argument types — give these arguments as RQL values (as in rql-mutate): {key: value, …}, [a, b], "text", 1.5, true, ref("Node3D#12") from a query result, godot.find("Name"); leave out keys you do not need: SerializedMemberList — named values {count: 3, label: "x", target: ref("Node3D#12")}: each is passed as a parameter of the value's type (a node, string, int, float, bool)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| usings | No | Extra namespaces for snippet mode, e.g. ["MyGame.Gameplay"]. | |
| include | No | Helper .cs files or folders (recursive) compiled with the code, relative to <project>/.ai-game-dev/snippets. | |
| timeout | No | Time budget of the run in seconds (default 30, at most 240; 0 = default). When it runs out the code is stopped at its next loop iteration or call and the call fails with Timeout; give long-running work a larger value. | |
| className | No | Full mode: the class whose static method runs (namespace-qualified or not). | |
| csharpCode | Yes | C# code. Snippet: 'var root = EditorInterface.Singleton.GetEditedSceneRoot();\nroot.GetChildCount()' (System, LINQ and Godot are imported; the last expression is the result, so no ';' after it). Full: 'using Godot;\npublic class Script { public static int Main() { return 42; } }' (full code brings its own usings). | |
| methodName | No | Full mode: the static method to run. | |
| parameters | No | Values for the snippet's / method's parameters by name, e.g. {node: ref("Node3D#12"), n: 6}. Leave empty if there are none. RQL: SerializedMemberList | |
| isMethodBody | No | Force snippet mode even when the code declares 'className'. |