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

Script to change character token image back and forth.

June 25 (6 years ago)

Edited June 25 (6 years ago)

Might be playing a shapechanging type character in an upcoming campaign who shifts between the same 2 forms back and forth.  Was wondering if there is a script or something I could use as a player to change back and forth between tokens on the fly, while keeping things such as hit points the same.  


First time looking for such a thing so if I posted in the wrong section sorry.

June 25 (6 years ago)
Andrew R.
Pro
Sheet Author

You can do this without needing a script by asking the GM or game Creator to make a rollable table token for the shapechanger character. 

Then the API script Change Token Image can change the facing without using the menus.

I use a rollable table token and token-mod to automatically calculate health on the new form. 

There's a thread in the pro-forums which explains how to do it. As you asked for a script I suppose you can read this:

https://app.roll20.net/forum/post/7530555/new-to-macro

June 25 (6 years ago)

Edited June 25 (6 years ago)

Reading about rollable table tokens now.


Also that link you provided doesn't take me to anything about macros, it takes my to the list of games I am playing in oddly enough....

June 25 (6 years ago)

Edited June 25 (6 years ago)

Managed to make a changing token in my test game.  Is there a way to set it up so the player can change the token him/herself, or is the GM the only one who can do it.

June 26 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter


Jared A. said:

Also that link you provided doesn't take me to anything about macros, it takes my to the list of games I am playing in oddly enough....

It was a link to the Pro subscriber forum. Without a Pro subscription your best bet is the rollable table token outlines above, changing the face with a right click.


June 27 (6 years ago)

Gotcha thanks, our DM has Pro, I was just trying to figure it all out before hand to save him time.

June 27 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

If you decide to use TokenMod for this, here are the relevant parts of the help:

SideNumber

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: 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 + or - 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 ?, 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 *. 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 TurnMarker1):

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: Because of a Roll20 bug with @{target|} and the API, you must specify the tokens you want to change using --idswhen using @{target|}.

Multi-Sided Token Options

You can append additional images to the list of sides by prefacing the source of an image with +:

!token-mod --set imgsrc|+@{target|token_id} --ids @{selected|token_id}

If you follow the + with a =, 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 : 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 = 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 , separated list:

!token-mod --set imgsrc|+@{target|token_id}:3,4,5,9 --ids @{selected|token_id}

Using = 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 * after the : 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 - 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 - with a , 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 - with an * 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: 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, using:

!token-mod --help