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

Using api script for fx spawn on layer change

So I recently got Pro after seeing some of the cool things a fellow DM could do with scripting and one thing I really wanted to try and figure out was if there is a way to set up a script for a few tokens that are on the gem layer to spawn an effect when they are changed to the token layer, giving an effect, for example, that they have teleported in with a magical explosion. I was thinking the way to do this was create a macro to move the tokens and then create a macro to spawn the effect and then a script to run the 2nd if the first is run or something along these lines but I'm not sure. I'm not super experienced with JS but I was wondering if there is an easier way to do this or if I'm on the right track. Would really appreciate any tips/pointers!

June 20 (5 years ago)
Oosh
Sheet Author
API Scripter

TokenMod can change the layer of a token - if you combine this in a macro with the FX you need it should work. Something like


/fx nova-holy @{selected|token_id}

!token-mod --set layer|objects

The FX can be pretty laggy, I don't know if there's any way to synchronise this properly.