run_lua
Execute Lua code within Aseprite to automate sprite editing and animation tasks with full API access. Returns results as JSON.
Instructions
Runs Lua code inside Aseprite with the full scripting API (app, Sprite, Image, Layer, Color, ...). Globals: args (your args object), sprite (resolved sprite or app.sprite), MCP (helper runtime: MCP.color(), MCP.layer(spr, ref), MCP.sprite_info(spr) ...). print output is captured. The return value is sent back as JSON. Use api_docs for the API reference.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | Values available to the code as `args` | |
| code | Yes | Lua source. Use `return` to send a value back. | |
| save | No | Batch mode: write changes back to the sprite file (default true) | |
| sprite | No | File path, open tab title, or sprite id. Defaults to the active sprite (live). Batch mode needs a file path. | |
| backend | No | auto (default): live Aseprite if connected, else headless batch | |
| mutates | No | Batch mode: false skips saving the sprite afterwards (default true) |