Overview
Aseprite includes a powerful scripting API that allows you to automate tasks, create custom tools, and extend the functionality of the editor. Scripts are written in Lua, a lightweight and easy-to-learn programming language.What Can You Do with Scripts?
Aseprite’s scripting API provides access to:- Sprite manipulation: Create, modify, and save sprites programmatically
- Layer and frame operations: Add, delete, and organize layers and frames
- Drawing operations: Use tools like pencil, line, and paint bucket from scripts
- Image processing: Access and modify pixel data directly
- File operations: Batch process multiple files
- UI dialogs: Create custom dialogs for user interaction
- Command execution: Run any Aseprite command from scripts
The Lua API
The Aseprite Lua API is accessed through the globalapp object, which provides:
Core Objects
app.activeSprite- The currently active spriteapp.activeLayer- The currently selected layerapp.activeFrame- The current frame numberapp.activeCel- The currently selected celapp.activeImage- The image in the active cel
Main Classes
- Sprite: Represents an Aseprite document
- Layer: A layer in the sprite hierarchy
- Cel: A cel (image in a specific frame)
- Image: Pixel data and image manipulation
- Color: Color values and color spaces
- Rectangle: Rectangular regions
- Point: 2D coordinates
- Selection: Selection masks
Script Locations
Aseprite looks for scripts in the following locations:- User scripts folder:
File > Scripts > Open Scripts Folder - Scripts placed here appear in the
File > Scriptsmenu - You can organize scripts in subdirectories
Running Scripts
There are several ways to run scripts:- From the menu:
File > Scripts > [Your Script] - Using the command line:
- Using keyboard shortcuts: Assign shortcuts in
Edit > Keyboard Shortcuts > Scripts
Example: Hello World
Here’s a simple script that prints a message:Example: Creating a Sprite
Example: Drawing on the Canvas
Color Modes
Aseprite supports three color modes:Working with Pixels
Undo/Redo Support
Many operations automatically create undo history entries:Error Handling
Use Lua’spcall for error handling:
Next Steps
Your First Script
Write and run your first Aseprite script
Automation Examples
Automate repetitive tasks
Batch Processing
Process multiple files at once
Custom Tools
Create custom drawing tools

