Create a layer by script

Also check sprite:newLayer() api/sprite.md at main · aseprite/api · GitHub

If you have a template .ASE file with your layers, you could copy the desired layer from that file (using templateSprite.layers[index] then do something like

--newSprite is the new file to receive the clone
local newLayer = newSprite:newLayer()
newLayer = templateSprite.layers[someIndex]

Which would clone the template layer’s name, settings, blending mode, opacity etc, and in theory, all its frames/cels as well. But keep in mind you’ll also need to define the receiving sprite’s canvas size (its bounds).

And lastly, be aware that if the template has an indexed color mode, it might copy a garbage image because the receiving end won’t have the same palette. If it’s just one frame/one cel, a useful way to circumvent that mess would be using image:drawImage() api/image.md at main · aseprite/api · GitHub (you’d probably have to hide all the other layers so it only copies the pixels from the one you choose)

If you want to delve further, this sample script and this script (for the hide/show layers part of the algorithm) would be a nice starting point, though there might be simpler methods.

1 Like