Moving layers via extension API?

Hey, I’m trying to figure out how to move layers with the extension API. Setting the layer.stackIndex doesn’t seem to do anything, despite the documentation here.

For example, this code will print the ‘correct’ stack indexes for the layers (1 for the newly created layer, and 2 for the existing one, in theory putting it below the existing layer), but the layers are not actually moved inside of aseprite’s UI.

local currentLayer = app.layer
currentLayer.stackIndex = 2
local lowerLayer = app.sprite:newLayer()
lowerLayer.stackIndex = 1

This prints out 2, 1 as expected, but the layers are not actually in that order in the timeline, the existing layer is below the newly created (and lower stack index) layer.

Any way of moving layers via the API, or creating layers in a specific location in the stack would be appreciated.

1 Like