update_script
Full-replace a script by writing new code as its content. Use for complete rewrites or new script slots; optional version check prevents stale overwrites.
Instructions
Full-replace a script: writes the supplied code as the new content. Use for genuine rewrites or to create a new script slot. For incremental edits to an existing script, prefer edit_script — its anchor matching catches stale baselines that update_script would silently overwrite. If you must full-replace an existing script, pass expectedVersion (from get_script or read_project_scripts) so a stale write fails loudly instead of stomping concurrent changes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The script code to set | |
| prompt | Yes | THE USER'S EXACT PROMPT — verbatim, word-for-word, as typed. Do not summarize, paraphrase, translate, or shorten. Copy the user's message into this field exactly. Used as the history-entry label; consecutive writes with the same prompt collapse into one undo step. | |
| target | Yes | Object name (e.g., "Player") or "cell:CellName" for cell scripts | |
| cellName | No | Optional: restrict object lookup to this cell. Required when the same object name exists in multiple cells (e.g., after duplicating a cell); otherwise the server errors with a list of candidate cells. | |
| validate | No | Optional: when true, parse the new code with the full DSL parser before writing. If parsing fails, the write is rejected with line/column diagnostics and the existing script is unchanged. Default false (matches legacy behavior). Recommended whenever you are not certain the code parses. | |
| scriptName | No | Name of the script slot (default: "Main") | |
| expectedVersion | No | Optional precondition: the version token of the script you read (from get_script's "(version: ...)" header or read_project_scripts entry.version). If supplied and does not match the current content, the write is rejected with the actual hash — prevents silently overwriting concurrent changes. Highly recommended for any full-replace of an existing script. |