Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Reorder z-order for specific tokens

I have a handful of spell templates that I have created as journal entries with tokens sized and linked to them.  This allows characters to quickly pull out say a "20 foot radius", however the problem is this always ends up being "on top" of everything as far a z ordering goes. Ultimately what I would like to do is: Define specific tokens Have those tokens sent "to back" when dropped on the object layer Is there a utility script that does this?  If no, can someone give me an idea where to start?  I think that I need to create a command that will define the specific token ids to send to back, probably saving to state (I have never messed with state... always worried that I might bork something up).  Then it seems like the z-order is set on the page object, but it seems like it is a read-only object, but there is a note that it can be reordered, but not sure how.  If it can be reordered, then I would think the next thing to do would be 'on("add:graphic", function(obj){})'. It seems possible, but not terribly familiar with how to define the specific tokens that I want this to work with, and it's also unclear how to reorder the z-order for the token layer on the page.  Any help, or samples to get me started would be appreciated.
1493576410
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Token mod will allow you to send a token to the back. You might want to look in my thread on  spell effect tokens for some ideas.
1493581791
PaprikaCC
Pro
API Scripter
A really easy way is just to name all of the spell effects a certain way and use something like: on('add:graphic', (obj) => { if (obj.get('layer') !== 'objects') return; if (obj.get('name') === 'name of your spell FX') toBack(obj); });
PaprikaCC said: A really easy way is just to name all of the spell effects a certain way and use something like: on('add:graphic', (obj) => { if (obj.get('layer') !== 'objects') return; if (obj.get('name') === 'name of your spell FX') toBack(obj); }); Thanks, I was unaware of the toBack() function, that answers a big part of what I was looking for as far as reordering.  However, it seems it isn't that simple, because it seems that the token objects don't have names when dragged in from the Journal.  Messing around with it to see if I can get things working, but having some odd behavior.
1493605388
The Aaron
Pro
API Scripter
Take a look at how TokenNameNumber deals with token adjustments on token creation. It turns out to be a little unintuitive initially. (I just modified TNN because there are now 3 events for dragging a token from the journal and you want the third one. However, there are only 2 for copy paste!) Created tokens get a new token id each time, so token ids are only useful for tracking existing tokens. Using the name, the character name it represents, or an attribute of a represented character would probably be the most reliable method.
Thanks, this helped.  I got things working well for the specific case I wanted to cover.