Setting Up
Before writing your first script, you need to know where to save it.Opening the Scripts Folder
- Open Aseprite
- Go to
File > Scripts > Open Scripts Folder - This opens your user scripts directory
- Windows:
C:\Users\YourName\AppData\Roaming\Aseprite\scripts - macOS:
~/Library/Application Support/Aseprite/scripts - Linux:
~/.config/aseprite/scripts
Creating Your First Script
Let’s create a simple script that creates a new sprite and draws a red square.Step 1: Create the Script File
- In your scripts folder, create a new file called
my-first-script.lua - Open it in your favorite text editor
Step 2: Write the Script
Add the following code to your script:my-first-script.lua
Step 3: Run the Script
- In Aseprite, go to
File > Scripts > Rescan Scripts Folder - Then go to
File > Scripts > my-first-script - Your script will run and create a new sprite with a red square
Understanding the Code
Let’s break down what each part does:Creating a Sprite
Printing Messages
print() function outputs text to the console. You can see these messages in the Aseprite console or terminal (if running from command line).
Defining Colors
Using Tools
app.useTool() function simulates using a drawing tool. Parameters:
tool: The tool name (e.g., ‘pencil’, ‘line’, ‘filled_rectangle’)color: The color to draw withbrush: The brush to use (size and shape)points: The points where to apply the tool
Common Tools
Here are some commonly used tools:Accessing the Active Sprite
Instead of creating a new sprite, you can work with the currently open sprite:Working with Layers
Working with Frames
Saving the Sprite
Adding User Input with Dialogs
You can create dialogs to get input from users:Running Scripts from Command Line
You can run scripts without opening the Aseprite UI:Debugging Tips
Print Variables
Check for Nil Values
Use Assert
Error Handling
Practice Exercises
Try creating these scripts to practice:- Checkerboard Pattern: Create a sprite with a checkerboard pattern
- Rainbow Gradient: Draw a horizontal rainbow gradient
- Circle Drawer: Create a script that draws circles at random positions
- Layer Manager: Create a script that creates multiple named layers
- Frame Animation: Create an animation by drawing different content on each frame
Next Steps
Automation Examples
Automate repetitive tasks with scripts
Batch Processing
Process multiple files efficiently
Custom Tools
Create your own drawing tools
API Reference
Complete API documentation

