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

[Question] Any Way for the API to Change the Z Order of Objects?

1368132059
Konrad J.
Pro
API Scripter
If not, any plans on that possibility?  I've got an idea that it would be useful.  Sometimes it might be useful to force something to be on top or on the bottom?
I'm with you on this-- I like making somewhat axonometric tokens that look like miniatures with bases, and I'd love to change their z order based on vertical position.
The whole z-order thing can be surprisingly complicated. If you change it on one object you have to update the order for all objects (obviously). It would be fairly easy to add a toFront()/toBack() command, but it will be harder to add something to let you set a specific z-order yourself (e.g. to set the z-order of a bunch of objects all at once). I'll look into it though.
A toFront()/toBack() command would pretty much suffice, since I can poll the tokens and sort them by one of their transform metrics, then just step through and assign each toFront() as I step through the list. I think I can poll the tokens... forEach(), right?
1368550147
Konrad J.
Pro
API Scripter
Riley D. said: The whole z-order thing can be surprisingly complicated. If you change it on one object you have to update the order for all objects (obviously). It would be fairly easy to add a toFront()/toBack() command, but it will be harder to add something to let you set a specific z-order yourself (e.g. to set the z-order of a bunch of objects all at once). I'll look into it though. Front to back would be useful I think.  I'm thinking what I want it for would be to hide or show a token.  Lets say for example you had a graphic that was 4x8 units (the dice tray).  And you had a bunch of dice graphics.  You could hide them all under the tray and then just show the ones that are rolled. :)  Another way to hide tokens is simply to make their left,top = 0,0 I found.  But I still need a way to bring tokens to the front or back.  Its not a must, but could be useful for scripts.