script_patch
Apply targeted find-and-replace, append, or prepend edits to Godot resource files, validated atomically to prevent corruption.
Instructions
Surgically edit an existing res:// file without rewriting it whole. edits = an ordered array; each item is {find, replace[, all]} (find must match EXACTLY once unless all:true), {append: text}, or {prepend: text}. Atomic + safe: nothing is written if any anchor is missing/ambiguous or (for .gd) the result fails to compile. Prefer this over write_script for small changes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | res:// path to an existing file | |
| edits | Yes | [{find, replace, all?} | {append} | {prepend}] applied in order | |
| validate | No | compile-check the result before writing (default true, .gd only) |