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

Run GIFs on Token Using API

Hi, Me again.&nbsp; I've been busy making use of some really excellent scripts and have used TokenMod and others to create flippable tokens for wild-shaping druids and polymorphing spellcasters.&nbsp; For the druid, I'd like to run a gif (like this one -&nbsp; <a href="https://i.imgur.com/zH10lWK.gif" rel="nofollow">https://i.imgur.com/zH10lWK.gif</a>) &nbsp;when he wild shapes rather than the current animation - currently done using this macro: /fx explode-smoke !token-mod --set currentside|1 Is there a way to have GIFs execute on a token, even if only once, so I can give different characters different effects?
1623928909

Edited 1623929040
Oosh
Sheet Author
API Scripter
Hrmmm, the API has a bunch of limitations on the images you can assign to a token. They need to be in your library, and they need to be the thumb sized version (AFAIK). I think the easiest way to do it would be to create a Rollable Table/Token with all the animations you want on different sides, then use either a custom script or just a macro with a bunch of tokenMod commands to set the correct Side/Height/Width, and set the Top/Left position from the token you'd like to play the animation over. Then you'd just need an "animation off" macro which changes the token to side 1 (a transparent png) and moves it to [70,70] or somewhere out of the way. It's a bit fiddly, but creating a fresh token with a GIF isn't possible through API as far as I know. I only have a couple in my Library, but they're converted to .webm and don't appear to have a .thumb version, so you can't apply them to tokens on the fly. As for the timing of the animation, if you want to include that you'd probably need to go for the custom script option - you can call tokenMod from there to keep it simple if you'd like, but you can at least store an object in your script that has the 'settings' for each animation. Kind of a mock-up of what I'm talking about: //&nbsp;animation&nbsp;settings&nbsp;object const &nbsp; animation &nbsp;=&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp; off : &nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; side : &nbsp; 1 , &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width : &nbsp; 70 , &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height : &nbsp; 70 , &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timer : &nbsp; null &nbsp;&nbsp;&nbsp;&nbsp;}, &nbsp;&nbsp;&nbsp;&nbsp; leaves : &nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; side : &nbsp; 2 , &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width : &nbsp; 140 , &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height : &nbsp; 210 , &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timer : &nbsp; 3000 , &nbsp;&nbsp;&nbsp;&nbsp;} } //&nbsp;Command&nbsp;line&nbsp;for&nbsp;animation handleInput (&nbsp; /*&nbsp;grab&nbsp;the&nbsp;animation&nbsp;you&nbsp;want&nbsp;from&nbsp;a&nbsp;chat&nbsp;macro,&nbsp;e.g.&nbsp;!anim&nbsp;--leaves&nbsp;--druidLady&nbsp;*/ ); //&nbsp;Grab&nbsp;whatever&nbsp;other&nbsp;info&nbsp;you&nbsp;need getData (&nbsp; /*&nbsp;grab&nbsp;top/left&nbsp;coordinates&nbsp;of&nbsp;druidLady&nbsp;*/ ); //&nbsp;Let&nbsp;tokenMod&nbsp;do&nbsp;the&nbsp;heavy&nbsp;lifting sendChat ( /*&nbsp;tokenmod&nbsp;--set&nbsp;commands&nbsp;with&nbsp;animation.leaves.side,&nbsp;animation.leaves.width&nbsp;etc.&nbsp;etc.&nbsp;*/ ); //&nbsp;Use&nbsp;a&nbsp;timer&nbsp;if&nbsp;it's&nbsp;set,&nbsp;otherwise&nbsp;you&nbsp;can&nbsp;use&nbsp;a&nbsp;manual&nbsp;macro&nbsp;to&nbsp;switch&nbsp;it&nbsp;off if &nbsp;( animation . leaves . timer &nbsp;&gt;&nbsp; 0 )&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp; setTimeout (()&nbsp; =&gt; &nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sendChat ( /*&nbsp;tokenmod&nbsp;--set&nbsp;commands&nbsp;for&nbsp;the&nbsp;"animation&nbsp;off"&nbsp;side&nbsp;of&nbsp;the&nbsp;token&nbsp;*/ ); &nbsp;&nbsp;&nbsp;&nbsp;},&nbsp; animation . leaves . timer ); } Or.... maybe a script already exists that will do it all for you! Or... maybe this a stupid way to do it anyway! But it would probably work. edit - I'm assuming you'd like the animation to play in addition to having the character token on the canvas, replacing the /fx essentially
1623934429
The Aaron
Roll20 Production Team
API Scripter
I was working on a frame-by-frame animator at one point, but I didn't finish it. Too much trouble trying to get it to look smooth.&nbsp; The API can create or set webm tokens, but it cannot start/stop them animating. It's a feature we'd love though, so hopefully we'll see it at some point.&nbsp;
Thanks both, that's really helpful. Oosh - I will have a look at your suggestion as I do like the idea but if there isn't a script for it already, it probably falls more into the nice to have box.&nbsp; But thank you, I'll look at your suggestion before our game tomorrow night. The Aaron - thank you for your help again.&nbsp; Is there a way to vote on this kind of feature?
1623938976

Edited 1623938988
timmaugh
Forum Champion
API Scripter
Have you looked into a custom FX ? You might be able to mimic the effect you're going for using native Roll20 features available to Pro subscribers -- so... you. =D
1623944495
The Aaron
Roll20 Production Team
API Scripter
Here's a suggestion:&nbsp; <a href="https://app.roll20.net/forum/post/7651466/slug%7D#post-8495664" rel="nofollow">https://app.roll20.net/forum/post/7651466/slug%7D#post-8495664</a> 41 votes so far.&nbsp;
Thanks Tim, I need to look at how to build Custom FX - I altered one a few days ago but need to look into how they are built more.&nbsp; I think it's probably my best bet for now
1623955802

Edited 1623956073
David M.
Pro
API Scripter
If you want a transformation-type effect in addition to custom fx, you could "spawn" yourself using the SpawnDefaultToken script. Click the first example in this post to see what that might look like. You are essentially deleting the first token (with "shrink" animation) and spawning a new version at the same spot (with "grow" animation). It works with rollable table tokens also, using the --side| command, although if the stats change it would probably be better to spawn a token from a different character sheet set up for that creature. You can trigger fx with the script&nbsp;at the origin point of the spawn using the --fx| command, too. The only thing is that it wouldn't retain the original token's condition markers, if any, as it uses the default token for the character sheet which wouldn't "see" the current token. Maybe a future feature? Oh, another important note: if you (1) use linked bar values and if you (2) go the "spawning yourself" route rather than a separate character sheet, there are some extra lines to add to make sure the current values don't get overwritten with an "old" copy of the character's default token, described here .&nbsp;