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] Modify Token Image

ModifyTokenImage Modify what your tokens look like, without roll tables, and customize what should be shown. Current Version: 1.0.4 Wiki Link: &nbsp; <a href="https://wiki.roll20.net/Script:Modify_Token_Image" rel="nofollow">https://wiki.roll20.net/Script:Modify_Token_Image</a> Code Repository (Roll20 API Script Github): &nbsp; <a href="https://github.com/Roll20/roll20-api-scripts/tree/master/ModifyTokenImage" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/tree/master/ModifyTokenImage</a> Modify Token Image is a script that utilizes the Handout functionality to be able to replace Token Images if needed. For example, if you have an end-game boss that is actually mimicking as some friendly creature, using Polymorph, you'd probably want players to see that token as Polymorphed into the creature you come to expect. However, in order to correctly make this happen, you would need two tokens, one with the polymorphed image, one with the real image of the creature. However, this API Script allows you to change between those tokens. Other examples include having creatures swap between Enemy and Friendly and having that signified by certain things. You can also swap out Token images for players that want to update their Tokens without completely replacing the tokens. This API Script requires that you create a Subfolder called "Token Images" in the Main Folder of your Library. Each token you want to enable with this functionality, you need to have a subfolder for the name of the Token, with one handout per state you want to switch. WARNING: This script modifies the GM Notes present on the Tokens that are modified, to keep track of what state each token is in (for next and previous). If you intend on using the GM Notes fields on Tokens, do not use this script, as it will overwrite the GM Notes with a JSON Array. You can add to the JSON Array to keep those notes, but if you modify the token GM Notes that are being set, you can corrupt the state of the token, and it will reset when another command is run. Commands: !ModifyTokenImage --next Changes the currently selected token's image to the next token valid token image in the folder for that token. !ModifyTokenImage --previous Changes the currently selected token's image to the previous token valid token image in the folder for that token. !ModifyTokenImage --set &lt;NameOfHandout&gt; Changes the currently selected token's image to the &lt;NameOfHandout&gt; image in that folder. !ModifyTokenImage --gm GM ONLY COMMAND &nbsp;Allows or disallows Player use of the above commands. NOTE: &nbsp;Even though players can use these commands, they can *only* execute these commands on tokens controlled by themselves. GMs can modify *all* tokens *always*. Also, this defaults to Players off. If you want to change the default, you need to change it in the script. !ModifyTokenImage --debug GM ONLY COMMAND &nbsp;Enables or disables Debug outputting to the log.
1555000861
The Aaron
Roll20 Production Team
API Scripter
Very creative, I’m looking forward to playing around with it. I do have a few minor suggestions for the code. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sendChat ( ' ModifyTokenImage ' , ' /w ' + msg . who + ' ' + contents); I’d suggest changing to: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sendChat ( ' ModifyTokenImage ' , ' /w " ' + msg . who + '" ' + contents); Names may have spaces (“The Aaron”, “The GM”, etc), putting them in quotes makes sure it goes to the right name (though names aren’t unique, so you can’t really guarantee it goes to the right person, but this gets you close.) You’re assigning to the msg.content property. It isn’t obvious, but every “chat:message” event handler will receive the identical msg object, so if you change it in one, you will change it for all. Since you are changing it before you check what the command is, you will break any other script that is depending on roll information in the message, and change the behavior of any script that looks for it &nbsp;I suggest cloning msg earlier in the handleInput() function and making modifications to the clone. My scripts that do this will take the argument as msg_orig and create a local variable named msg for the clone.
I was just playing around with it....pretty kewel... About ready to have party run into a series of lever puzzles obviously there are only 2 positions for levers....UP &amp; DOWN This is working great...so far...And I am seeing other possibilities... But if the wrong sequence is used, then they all will revert to down position... If I make a command&nbsp; !ModifyTokenImage --set &lt;LeverOff&gt; Every time I save it the&nbsp; &lt;LeverOff&gt;&nbsp; disappears&nbsp; not sure if this is a macro function that is causing this..? Cant even run it from chat window..?? I was hoping just to select all levers and run the off command...make life easier... :/
1555006397
The Aaron
Roll20 Production Team
API Scripter
Try it without the &lt; &gt; around it.&nbsp;
DOH.... :( I thought I did..... Worked....
Yeah, you can't use the &lt; &gt;, glad The Aaron solved it for you. @The Aaron: I plan on releasing an update that will use a different function for gathering the /w requirement. This is really my first script, and I plan on refactoring the structure anyways. I also didn't consider that each event would be getting the same object. I'll have to play around with it. I'm also going to be centralizing some scripts that I made, so I have to work on that.