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

Create Token with a webm image

1599086852

Edited 1599086935
I found this API in a youtube video and love it.&nbsp; Works like a charm for png files.&nbsp; But I have an animated webm file I bought and would like to use it but it doesn't work.&nbsp; Does anyone know if I need to use a different tag or change the code somewhat to put this token on the map? on("ready",function() { &nbsp;&nbsp;&nbsp; on("chat:message",function(msg){ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(msg.type=="api" &amp;&amp; msg.content.indexOf("!flamesphere")==0) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var selected = msg.selected; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (selected===undefined) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sendChat("API","Please select a character."); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var tok = getObj("graphic",selected[0]._id); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var character = getObj("character",tok.get("represents")); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var playerlist = character.get("controlledby") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; createObj("graphic",{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; left:tok.get("left")+70, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; top:tok.get("top"), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height:70, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width:70, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pageid:tok.get("pageid"), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; layer:"objects", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imgsrc:" <a href="https://s3.amazonaws.com/files.d20.io/images/159239444/uTBZXf0ABX4uWI8ku2Uy4w/thumb.png?15980541425" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/159239444/uTBZXf0ABX4uWI8ku2Uy4w/thumb.png?15980541425</a> ", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name:tok.get("name") + "'s Spiritual Weapon", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; controlledby:playerlist, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aura1_radius:0, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aura1_color:"#ff9900", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; showplayers_aura1:true &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spawnFx(tok.get("left")+70,tok.get("top"),"burst-fire",tok.get("pageid")); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp; }); });
1599090231
David M.
Pro
API Scripter
I don't have any experience with webm files, but I can tell you that when using the api to create token objects with an animated gif imgsrc, it doesn't work quite right. I've only ever gotten the animation to play oncem even when that same animated gif loops as expected when dragged manually from the journal. I think the api just doesn't play nicely with animated tokens :/ I'll be following this thread if somebody has a solution, though!&nbsp;
1599092919
The Aaron
Roll20 Production Team
API Scripter
David is correct.&nbsp; The API can't properly create Animated Tokens yet.
DOH! OK, plan B, can I somehow save it at the size I want?&nbsp; When I drag it from journal to the map it sizes itself to fit a square but I'd like it to come straight off much larger so I don't interrupt play with sizing.&nbsp; Admittedly I could just leave it on the DM layer for planned situations but this is a once in a while occurrence that might not happen on every map.
1599097120
timmaugh
Pro
API Scripter
Nothing to add, but full marks for the forum handle, Johnny. Well done.
Thanks, my first one got moderated so I had to tone it down a little.&nbsp; :(
1599098592
David M.
Pro
API Scripter
Johnny Meatshield said: OK, plan B, can I somehow save it at the size I want?&nbsp;&nbsp; Sure, first drag it to the map and size it the way you want. Then open the character sheet, click "edit", and where it says "default token (optional)", mouse over the image to reveal the "remove" option. Click that to remove, and then after ensuring that your resized token is selected, click on "use selected token", then save changes. The next time you drag it from the journal to the map, it should remember the new size.&nbsp;
I thought that's how that should work but it never works for me.&nbsp; Vision never saves, sizes never saves, etc.&nbsp; :(
1599111676
GiGs
Pro
Sheet Author
API Scripter
When that doesnt work, the error is nearly always messing up the order of the steps David outlines. After making any changes to a token on the map, you have to go back to the character sheet, delete the current default token, and set the updated token as the new default token, and save it.
There was my mistake.&nbsp; I thought once it was there I could do edits and just save.&nbsp; Didn't realize you had to delete the token every time.
1599149770
GiGs
Pro
Sheet Author
API Scripter
It is irritating that you have to do that, and very easy to overlook that step.