[1.3b69+] Token Image Swap

Show off your RPG maps, campaigns, and tokens. Share your gaming experiences and stories under General Discussion and save this forum for things you've created that may help others run their own games. Use the subforums when appropriate.

Moderators: dorpond, trevor, Azhrei, Gamerdude

Post Reply
User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

[1.3b69+] Token Image Swap

Post by aliasmask »

This is a fairly simple set of macros to swap your main image for an alternate image on your token. You can have up to 3 images on one token. The macros can be put on any token and it'll work. It's the poor man's alter self.

Functions on the Macro
  • Set Stage - This is your image chooser. Token comes default with "Magic Gate".
  • Setup - This sets the image chooser to the images on the token.
  • Reset - If you have not altered the portrait or handout image, this will restore the token image and clear the token properties. This is good to do when saving the token for later, but it won't break anything if you don't.
As a side note, if you don't want the Portrait image to show when you mouse over if your token is on the token layer, then after the setup, you can delete the portrait and/or handout image and it will still be a part of your selection. If you don't have the image in your local image repository, then it will be lost.[**]

**You can recover the image by exporting the campaign and manually editing that file to get the image back. I put instructions on the token, but it's a pain.

This one is good for image portability, but for a lib to drop in to your campaign that relies on your image asset cache try using Disguise. It has an unlimited number of image changes.
example.jpg
example.jpg (78.63 KiB) Viewed 2282 times
Macros

Code: Select all

  
@@Set Stage
@PROPS@ autoExecute=true ; color=blue ; fontColor=white ; group=Run ; includeLabel=false ; sortBy=6 ; index=2 ; fontSize=1.00em ; minWidth= ; playerEditable=true ; maxWidth= ; tooltip= ; applyToSelected=true ; 
[H: currentStage = getProperty("h.currentStage")]
[H, if(json.isEmpty(currentStage)), code: {
   [H, macro("Setup@this"):""]
   [H: currentStage = getProperty("h.currentStage")]
};{}]
[H: assetList = json.append("",getProperty("h.stage1"),getProperty("h.stage2"),getProperty("h.stage3"))]
[H: hasInput = input("stage| "+json.toList(assetList)+"||LIST|ICON=TRUE TEXT=FALSE SPAN=TRUE ICONSIZE=100 SELECT="+(currentStage-1))]
[H, if(hasInput), code: {
   [H: imgID = getProperty("h.stage"+(stage+1))]
   [H: setTokenImage(imgId)]
   [H: setProperty("h.currentStage",stage+1)]
};{}]

@@Reset
@PROPS@ autoExecute=true ; color=cyan ; fontColor=black ; group=Setup ; includeLabel=false ; sortBy=7 ; index=3 ; fontSize=0.95em ; minWidth= ; playerEditable=true ; maxWidth= ; tooltip= ; applyToSelected=false ; 
[H: currentImage = getTokenImage()]
[H: portraitImg = getTokenPortrait()]
[H: handoutImg = getTokenHandout()]
[H: stage1Image = getProperty("h.stage1")]
[H: stage2Image = getProperty("h.stage2")]
[H: stage3Image = getProperty("h.stage3")]
[H, if(stage1Image != ""), code: {
   [H: setTokenImage(stage1Image)]
   [H: resetProperty("h.stage1")]
};{}]
[H: flag = 0]
[H, if(stage2Image != "" && portraitImg == stage2Image): resetProperty("h.stage2"); flag = 1]
[H, if(stage3Image != "" && handoutImg == stage3Image): resetProperty("h.stage3"); flag = 1]
[H, if(flag), code: {
   [H: hasInput = input("confirm||<html>Your token images do not match the originals or token has already been reset.<br><br>The originals could be lost... are you sure?</html>|LABEL|TEXT=FALSE")]
   [H, if(1), code: {
      [H, if(!isPropertyEmpty("h.stage2")): resetProperty("h.stage2")]
      [H, if(!isPropertyEmpty("h.stage3")): resetProperty("h.stage3")]
      [H, if(!isPropertyEmpty("h.currentStage")): resetProperty("h.currentStage")]
   };{
      [H: inputStr = "junk||<html>If you do not have those images in your reference library,<br>it may be possible to recover them by exporting them as a<br>campaign repository file.  Change the file created extension<br>to .zip (for windows), open and browse the asset folder and<br>look for the following ids.  You can save/move them in to<br>your repository and add to appropriate image slot.<br><br><b>Portrait Image = "+substring(stage2Image,9)+"<br>Handout Image = "+substring(stage3Image,9)+"</b></html>|LABEL|TEXT=FALSE"]
      [H: input(inputStr)]
   }]
};{
   [H, if(!isPropertyEmpty("h.currentStage")): resetProperty("h.currentStage")]
}]

@@Setup
@PROPS@ autoExecute=true ; color=red ; fontColor=white ; group=Setup ; includeLabel=false ; sortBy=12 ; index=1 ; fontSize=0.95em ; minWidth= ; playerEditable=true ; maxWidth= ; tooltip= ; applyToSelected=false ; 
[H: currentStage = getProperty("h.currentStage")]
[H: tokenImg = getTokenImage()]
[H: portraitImg = getTokenPortrait()]
[H: handoutImg = getTokenHandout()]
[H: hasInput = input("choice|Are you sure you want to rewrite the images to the current configuration?||LABEL|SPAN=TRUE",
"token_| "+tokenImg+"|Token Image|LABEL|ICON=TRUE ICONSIZE=100",
"portrait_| "+portraitImg+"|Portrait Image|LABEL|ICON=TRUE ICONSIZE=100",
"handout_| "+handoutImg+"|Handout Image|LABEL|ICON=TRUE ICONSIZE=100")]
[H, if(hasInput), code: {
   [H: setProperty("h.stage1",tokenImg)]
   [H: setProperty("h.stage2",portraitImg)]
   [H: setProperty("h.stage3",handoutImg)]
   [H: setProperty("h.currentStage",1)]
};{}]
Attachments
ImageSwap.rptok
MT version 1.3b69+
(616.25 KiB) Downloaded 180 times
Last edited by aliasmask on Mon Jul 12, 2010 5:55 am, edited 3 times in total.

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: [1.3b69+] Token Image Swap

Post by aliasmask »

[RESERVED]

Malekith
Giant
Posts: 245
Joined: Wed Jan 07, 2009 4:36 pm
Location: Gloucester, England
Contact:

Re: [1.3b69+] Token Image Swap

Post by Malekith »

Yet again more brilliant work from Aliasmask.
Thank you sir, I shall definitely be including this in my future campaigns :D

Mal
Mal

Voltang
Cave Troll
Posts: 88
Joined: Wed Dec 03, 2008 5:13 pm

Re: [1.3b69+] Token Image Swap

Post by Voltang »

Finally, an easy way for my random Wanderer to reveal himself as a werewolf without making tables. Thank you sir!

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: [1.3b69+] Token Image Swap

Post by aliasmask »

I'm working on a single macro that will add an unlimited number of image change options, but the one limitation will be that the images are not transferable. It relies on your image cache. I think, but I'm not sure, but if create a blank campaign and drop all the images you'll ever want on to the background and export to campaign repository file. You can now use this zip file as a source for image assets which can be loaded locally or through a URL by adding it to your resource library.

I also believe any resource you have will be shared when used. So, for example, you drop a token on to a server. The token, including its current assets are shared. You change the image asset to a value you have in your cache or resource and the change and image is sent to other connected computers. The only time you have to worry about this is if you save it locally, email it to a friend and they open it up and try to change the image. The asset won't be there. You would have to send them your resource library as well to have them load it in to their campaign.

Voltang
Cave Troll
Posts: 88
Joined: Wed Dec 03, 2008 5:13 pm

Re: [1.3b69+] Token Image Swap

Post by Voltang »

Wildshaping Druids and polymorphing mages alone would thank you for your efforts.

Post Reply

Return to “User Creations”