Attach a script to a sprite or the stage
add_scriptCompile a JSON action list into executable Scratch blocks attached under a chosen hat event (e.g., flag click or key press) for a specified sprite or the Stage.
Instructions
Compiles a JSON action list into real Scratch blocks and attaches it under a hat block. Example: {"target":"Cat","when":"flag","do":[{"say":["Hi!",2]},{"forever":[{"move":4},"bounce_on_edge"]}]}. Call dsl_reference for every available action, expression and hat.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"target": "<target>",
"do": "<do>"
},
"name": "add_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| do | Yes | Ordered list of actions to run under the hat block | |
| when | No | Hat block: "flag" (default), "clicked", "clone", {"key":"space"}, {"broadcast":"go"}, "never" | |
| target | Yes | Sprite name, or "Stage" |