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 .
×
May your rolls be chill this holiday season!
Create a free account

Multi-Sided Tokens: Switching Sides Simply

Hi everyone,  I just recently obtained pro status and I have been playing around with API scripts. One thing I'm particularly interested in currently is simplifying switching sides on a rollable table token. I already have my token set up with four directional sides. But I was looking for a way to either "auto face" or a button system to change sides rather than the drop down menu.  Any help would be greatly appreciated! I saw in another thread mention of an api command button and token mod but I had some trouble determining the specifics. (Again, very new to this.)  Thank you again! 
1554547002

Edited 1554559160
GiGs
Pro
Sheet Author
API Scripter
TokenMod is the script you need. It will make handling tokens so much better in more ways than this. Create a macro like !token-mod --set currentside|?{Which Side?|0} And then just select a token, run it, enter a number, and it will change to that side. Make sure you dont enter a number for a side that doesnt exist. (I dont know how well tokenmod handles that, but i imagine it will just fail silently.) Edit: Oops - Aaron's post made me realise I set the query default to 0 instead of 1. It should have been !token-mod --set currentside|?{Which Side?|1}
1554553833
The Aaron
Roll20 Production Team
API Scripter
Here’s the full details on image and side from the TokenMod help: This is the index of the side to show for Multi-Sided tokens. Indicies start at 1. If you have a 6-sided token, it will have indicies 1, 2, 3, 4, 5 and 6. An empty index is considered to be 1. If a token doesn't have the index specified, it isn't changed. NOTICE: &nbsp;This only works for images in the User Image library. If your token has images that are stored in the Marketplace Library, they will not be selectable with this command. You can download those images and upload them to your User Image Library to use them with this. Available SideNumber Properties: currentside Setting a token to index 2: !token-mod --set currentside|2 Not specifying an index will set the index to 1, the first image: !token-mod --set currentside| You can shift the image by some amount by using&nbsp; + &nbsp;or&nbsp; - &nbsp;followed by an optional number. Moving all tokens to the next image: !token-mod --set currentside|+ Moving all tokens back 2 images: !token-mod --set currentside|-2 By default, if you go off either end of the list of images, you will wrap back around to the opposite side. If this token is showing image 3 out of 4 and this command is run, it will be on image 2: !token-mod --set currentside|+3 If you preface the command with a&nbsp; ? , the index will be bounded to the number of images and not wrap. In the same scenario, this would leave the above token at image 4: !token-mod --set currentside|?+3 In the same scenario, this would leave the above token at image 1: !token-mod --set currentside|?-30 If you want to chose a random image, you can use&nbsp; * . This will choose one of the valid images at random (all equally weighted): !token-mod --set currentside|* Image The Image type lets you manage the image a token uses, as well as the available images for Multi-Sided tokens. Images must be in a user library or will be ignored. The full path must be provided. Available Image Properties: imgsrc Setting the token image to a library image using a url (in this case, the orange ring I use for&nbsp; TurnMarker1 ): !token-mod --set imgsrc| <a href="https://s3.amazonaws.com/files.d20.io/images/4095816/086YSl3v0Kz3SlDAu245Vg/max.png?1400535580" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/4095816/086YSl3v0Kz3SlDAu245Vg/max.png?1400535580</a> Setting the token image from another token by specifying it's token_id: !token-mod --set imgsrc|@{target|token_id} --ids @{selected|token_id} WARNING: &nbsp;Because of a Roll20 bug with @{target|} and the API, you must specify the tokens you want to change using&nbsp; --ids &nbsp;when using @{target|}. Multi-Sided Token Options You can append additional images to the list of sides by prefacing the source of an image with&nbsp; + : !token-mod --set imgsrc|+ <a href="https://s3.amazonaws.com/files.d20.io/images/4095816/086YSl3v0Kz3SlDAu245Vg/max.png?1400535580" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/4095816/086YSl3v0Kz3SlDAu245Vg/max.png?1400535580</a> !token-mod --set imgsrc|+@{target|token_id} --ids @{selected|token_id} If you follow the&nbsp; + &nbsp;with a&nbsp; = , it will update the current side to the freshly added image: !token-mod --set imgsrc|+=@{target|token_id} --ids @{selected|token_id} When getting the image from a token, you can append a&nbsp; : &nbsp;and follow it with an index to copy. Indicies start at 1, if you specify an index that doesn't exist, nothing will happen: !token-mod --set imgsrc|+@{target|token_id}:3 --ids @{selected|token_id} You can specify the&nbsp; = &nbsp;with this syntax: !token-mod --set imgsrc|+=@{target|token_id}:3 --ids @{selected|token_id} You can specify multiple indices to copy by using a&nbsp; , &nbsp;separated list: !token-mod --set imgsrc|+@{target|token_id}:3,4,5,9 --ids @{selected|token_id} Using&nbsp; = &nbsp;with this syntax will set the current side to the last added image: !token-mod --set imgsrc|+@{target|token_id}:3,4,5,9 --ids @{selected|token_id} Images are copied in the order specified. You can even copy images from a token you're setting. !token-mod --set imgsrc|+@{target|token_id}:3,2,1 --ids @{selected|token_id} You can use an&nbsp; * &nbsp;after the&nbsp; : &nbsp;to copy all the images from a token. The order will be from 1 to the maximum image. !token-mod --set imgsrc|+@{target|token_id}:* --ids @{selected|token_id} You can remove images from the image list using&nbsp; - &nbsp;followed by the index to remove. If you remove the currently used image, the side will be set to 0. !token-mod --set imgsrc|-3 If you omit the number, it will remove the current side: !token-mod --set imgsrc|- You can follow the&nbsp; - &nbsp;with a&nbsp; , &nbsp;separated list of indicies to remove. If any of the indicies don't exist, they will be ignored: !token-mod --set imgsrc|-3,4,7 You can follow the&nbsp; - &nbsp;with an&nbsp; * &nbsp;to remove all the images, turning the Multi-Sided token back into a regular token. (This also happens if you remove the last image by index.): !token-mod --set imgsrc|-* WARNING: &nbsp;If you attempt to change the image list for a token with images in the Marketplace Library, it will remove all of them from that token. Full Help,&nbsp; using: !token-mod --help Thanks&nbsp; keithcurtis &nbsp;and&nbsp; Lady Victoria &nbsp;for the suggestions!
Thank you both for the help! I was able to get it to work pretty easily, it will add a lot of style to the campaign.&nbsp; Thank you again!