Scripting help: layer tagging system!

I couldn’t decide whether I should put this post in Help, in Scripts & Extensions, or in Development, so I apologize if it’s in the wrong place.

There are a couple of features that aren’t in Aseprite right now that I would love to see, so I figured I might just try to make them myself using the Lua scripting interface. I’m looking for help with some parts of doing that. This post is a bit long, though, so I’m only going to ask about one of them here, and I’ll make a separate post for the other one. (I hope that’s alright!)

I want to be able to assign a “tag” to a layer, and then make it so that I can toggle the visibility of everything with that tag. (I believe this has been requested before.)

For example, say I’m making a character, and I have one layer for their “front” hair (like their bangs/fringe or whatever), another layer for their “mid” hair (like the hair on the top and sides of their head), and another layer for their “back” hair (the rearmost layer of hair, the hair that flows down their back if it’s long). I would like to be able to tag all three of these layers as hair layers, and then with one button press, hide or show all the hair layers at once. Note that I can’t just put them all in a group and toggle its visibility, because I have the character’s face between the front and mid hair layers, and I have their body in front of the back layer. I could use this same system to tag “clothing” or “armor” layers, or really anything at all that represents one thing that needs to be drawn on separate layers with other layers between them.

My idea is to assign tags to a layer via its User Data field, and then create some kind of UI window or dialog or whatever that resembles the main Timeline, with a vertically stacked list that contains an entry for each tag I’ve created, and some controls to the side of that, allowing me to set visibility, opacity, etc.

There are two specific pieces of help I’m looking for with this approach (but I’m happy to entertain any idea that would get the results I’m looking for using some totally different approach). First of all, I want help deciding how to detect when I’ve added or removed a tag. I figure I could use a timer to look through all the layers periodically, say a few times every second, and check which tags are present. I think this would work, but it would be nice if there were some kind of event I could listen for that represented some changes made to a layer’s data.

Secondly, I would like help in dynamically building the vertical stack of UI elements, each corresponding to one of my tags, within my custom window. Admittedly I haven’t spent much time messing around with custom UI yet, so maybe there’s an easy way to do this, but I figure I’ll need to be able to create and delete some of these things while the script is running, as I add and remove tags to and from my layers. I have a few vague ideas for how I might do this, but I would love to hear from anyone who has any insight to share on the matter.

Thanks in advance to anyone who can help!

As interesting as building a custom system like this with a custom UI would be, it might not be necessary in your case.

If you’re building characters out of a static set of layers, and some elements should have parts on different heights (some part is on the front, some part is on the very back) you can still just pack them into a group and use the cels z-index to make some parts of these elements show up higher/lower than their actual placement on the timeline.


Holy crud, I had no idea this feature existed. I’m going to look extensively into it! Thanks so much.

1 Like