Script Patch
script_patchReplace exact code snippets in Godot .gd or .cs files, with GDScript validation and in-memory refresh for immediate execution.
Instructions
Anchor-based string-replace edit on a .gd or .cs file.
Finds an exact old_text and replaces with new_text. Fails
on multiple matches unless replace_all=True; fails on zero matches.
Exact byte match (whitespace significant). Triggers filesystem scan.
.gd: parse-validated (diagnostics) and an already-loaded GDScript
is refreshed in place so the next call runs the new code (response
reloaded=true; otherwise reload_reason says why). .cs: text only —
diagnostics_status="not_checked", reload_reason= "csharp_requires_build"; rebuild the .NET assembly to run it.
Not undoable via Ctrl+Z.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | res:// path ending in .gd or .cs. | |
| new_text | Yes | Replacement (empty deletes). | |
| old_text | Yes | Exact substring to find. Must be unique unless replace_all. | |
| session_id | No | Optional Godot session to target. Empty = active session. | |
| replace_all | No | Replace every occurrence. Default False. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||