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

[Help] toBack(), why isn't it working?

Ok, I got this little script here, all it's supposed to do is find all tokens named "Flame" and "Flame2" and move them to the back of the layer, so they're behind the tokens, as soon as the GM types !flame in chat. Well actually it's supposed to do more once it's finished, but for now that's where it stops doing what it does, so I come here for help. Well, yes it doesn't work. At most it seems to move a single token to the back, probably the last one called, but I'm not sure about that. I tried delaying it or something, to give each token a little time to move to the back before moving on to the next, but somehow that didn't seem to delay anything, so I think I did that wrong. <a href="https://gist.github.com/Quatar/8983b75c01f61e60894d" rel="nofollow">https://gist.github.com/Quatar/8983b75c01f61e60894d</a>
Still no idea why it's not working, with toBack() but instead of doing that, I now moved the tokens to the map layer. Works for me, has the added advantage that I don't accidently target the stuff, when moving tokens around to kill my players. Still curious though as to why it's not working and what I could do to make it work.
I want to know what the deal is, too. &nbsp;I spent some time playing with your code, dropping in some debugging chat sends so I could see it iterate through the list. It iterates, but only applies the toBack() to one token. &nbsp;It's either the first or the last token, not sure which. I had intended to use the toFront/toBack functions in a similar manner, but I can't if these functions are going to misbehave.