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 Update] TokenMod -- An interface to adjusting properties of a token from a macro or the chat area.

1478727346

Edited 1568163601
The Aaron
Pro
API Scripter
Update v0.8.45 &nbsp;-- Fixed a bug where&nbsp; u , &nbsp; g &nbsp;relative units were being incorrectly scaled when the Grid Cell width was other than 1.&nbsp; My sincere apologies if that makes any of your existing macros incorrect, I wish I'd caught it before I released it.&nbsp; (Thanks&nbsp; Joe ) New --report feature, see details in the help or here:&nbsp; <a href="https://app.roll20.net/forum/permalink/7759266/" rel="nofollow">https://app.roll20.net/forum/permalink/7759266/</a> Update v0.8.44 &nbsp;-- Fixed bug with setting negative numbers as values. (Thanks&nbsp; Kilter ) Update v0.8.43 &nbsp;-- Added displaying 0 on status markers where that makes sense.&nbsp; Fixed ordering of status markers (Roll20 Update changed the ordering). Update v0.8.42 &nbsp;-- Added relative scaling for Units, the Grid, or the Scale of the Measure Units. (Thanks&nbsp; Joe ): You can follow a number by one of &nbsp; u , &nbsp; g , or &nbsp; s &nbsp; to adjust the scale that the number is applied in. Use &nbsp; u &nbsp; to use a number based on Roll20 Units, which are 70 pixels at 100% zoom. This will set a graphic to 280x140. !token-mod --set width|4u height|2u Use &nbsp; g &nbsp; to use a number based on the current grid size. This will set a token to the middle of the 8th column, 4rd row grid. (.5 offset for half the center) !token-mod --set left|7.5g top|3.5g Use &nbsp; s &nbsp; to use a number based on the current unit if measure. (ft, m, mi, etc) This will set a token to be 25ft by 35ft (assuming ft are the unit of measure) !token-mod --set width|25s height|35s Currently, you can also use any of the default units of measure as alternatives to &nbsp; s : &nbsp; ft , &nbsp; m , &nbsp; km , &nbsp; mi , &nbsp; in , &nbsp; cm , &nbsp; un , &nbsp; hex , &nbsp; sq !token-mod --set width|25ft height|35ft You can use that with light_radius, light_dimradius, light_multiplier, aura1_radius, aura2_radius, left, top, width, height, and scale. Additionally, I added a pseudo field Scale : scale &nbsp;is a pseudo field which adjusts both&nbsp; width &nbsp;and&nbsp; height &nbsp;with the same operation. This will scale a token to twice it's current size. !token-mod --set scale|*2 Update v0.8.41 &nbsp;-- Added ! for toggling Number or Blank fields (Thanks&nbsp; Lex ): !token-mod --set aura1_radius|!20 Update v0.8.40 &nbsp;-- Added adv_fow_view_distance setting (Thanks&nbsp; Wolf Thunderspirit ) Numbers or Blank Just like the Numbers fields, except you can set them to blank as well. Available Numbers or Blank Properties: light_radius light_dimradius light_multiplier aura1_radius aura2_radius adv_fow_view_distance Here is setting a standard DnD 5e torch, turning off aura1 and setting aura2 to 30. Note that the&nbsp; | &nbsp;is still required for setting a blank value, such as aura1_radius below. !token-mod --set light_radius|40 light_dimradius|20 aura1_radius| aura2_radius|30 Just as above, you can use&nbsp; = ,&nbsp; + ,&nbsp; - ,&nbsp; * , and&nbsp; / &nbsp;when setting these values. Here is setting a standard DnD 5e torch, with advanced fog of war revealed for 30. !token-mod --set light_radius|40 light_dimradius|20 adv_fow_view_distance|30 Update v0.8.39 &nbsp;-- Added Min and Max bounds to status marker numbers (Thanks&nbsp; Morgan ) You can append two additional numbers separated by&nbsp; : . These numbers will be used as the minimum and maximum value when setting or adjusting the number on a status marker. Specified minimum and maximum values will be kept between 0 and 9. !token-mod --set statusmarkers|blue:+1:2:5 Omitting either of the numbers will cause them to use their default value. Here is an example limiting the max to 5: !token-mod --set statusmarkers|blue:+1::5 Update v0.8.38 &nbsp;-- Fixed a bug that crept in around using negative numbers (Thanks&nbsp; Chris and&nbsp; Xttapalotakettle ) Update v0.8.37 &nbsp;-- Added two new arguments: --current-page, --active-pages :and fixed a few types (Thanks&nbsp; Joe M. ) --current-page If you add this to the command, it will only adjust tokens on the page that the issuer is currently on.&nbsp; For Players this is either the page they've been split to, or the page the party ribbon is on if they've not been split.&nbsp; For GM's this is the last page they loaded (which is pretty much the page they are on, unless they've got it open in multiple windows and the last changed pages on a different window). This is most useful when working with character ids, as the character might be on many pages, but you might want to restrict changes to only the current page. --active-pages If you add this to the command, it will only adjust tokens on pages where there are people.&nbsp; This means just the pages that have the party ribbon on them, have a player split to them or are the last page the GM loaded (if the current player is the gm).&nbsp;&nbsp; Note that this will still make changes even if the players on those pages are logged out.&nbsp;&nbsp; This is most useful when working with character ids, as the character might be on many pages, but you might want to restrict changes to only the tokens that are on pages where people are. Update v0.8.36 &nbsp;-- Updated the help system and added/expanded 3 section: Colors Colors can be specified in multiple formats: Transparent -- This is the special literal transparent and represents no color at all. HTML Color -- This is 6 or 3 hexidecimal digits, optionally prefaced by # . Digits in a 3 digit hexidecimal color are doubled. All of the following are the same: #ff00aa , #f0a , ff00aa , f0a RGB Color -- This is an RGB color in the format rgb(1.0,1.0,1.0) or rgb(256,256,256) . Decimal numbers are in the scale of 0.0 to 1.0, integer numbers are scaled 0 to 256. Note that numbers can be outside this range for the purpose of doing math. HSV Color -- This is an HSV color in the format hsv(1.0,1.0,1.0) or hsv(360,100,100) . Decimal numbers are in the scale of 0.0 to 1.0, integer numbers are scaled 0 to 360 for the hue and 0 to 100 for saturation and value. Note that numbers can be outside this range for the purpose of doing math. Available Colors Properties: tint_color aura1_color aura2_color Turning off the tint and setting aura1 to a reddish color. All of the following are the same: !token-mod --set tint_color|transparent aura1_color|ff3366 !token-mod --set tint_color| aura1_color|f36 !token-mod --set tint_color|transparent aura1_color|#f36 !token-mod --set tint_color| aura1_color|#ff3366 Setting the tint_color using an RGB Color using Integer and Decimal notations: !token-mod --set tint_color|rgb(127,0,256) !token-mod --set tint_color|rgb(.5,0.0,1.0) Setting the tint_color using an HSV Color using Integer and Decimal notations: !token-mod --set tint_color|hsv(0,50,100) !token-mod --set tint_color|hsv(0.0,.5,1.0) You can toggle a color on and off by prefacing it with ! . If the color is currently transparent, it will be set to the specified color, otherwise it will be set to transparent: !token-mod --set tint_color|!rgb(1.0,.0,.2) Color Math You can perform math on colors using + , - , and * . Making the aura just a little more red: !token-mod --set aura1_color|+#330000 Making the aura just a little less blue: !token-mod --set aura1_color|-rgb(0.0,0.0,0.1) HSV colors are especially good for color math. Making the aura twice as bright: !token-mod --set aura1_color|*hsv(1.0,1.0,2.0) Performing math operations with a transparent color as the command argument does nothing: !token-mod --set aura1_color|*transparent Performing math operations on a transparent color on a token treats the color as black. Assuming a token had a transparent aura1, this would set it to #330000. !token-mod --set aura1_color|+300 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 ): !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: Because of a Roll20 bug with @{target|} and the API, you must specify the tokens you want to change using --ids 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 + : !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 + 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 Thanks&nbsp; keithcurtis and&nbsp; Lady Victoria for the suggestions! Update v0.8.35 -- Changed finding of attributes to be case-insensitive. &nbsp;It turns out that the client interface only finds the first matching attribute and ignores case, so it's reasonable for the API to do the same. &nbsp;(thanks&nbsp; Alexander ) Update v0.8.34 &nbsp;-- Fixed the behavior of ! and - adjustments to statusmarkers when dealing with [] statuses. Using - with a [] status will now remove the rightmost instance of that status, rather than all of them. !token-mod --set statusmarkers|-blue[] Using ! with a [] status with now toggle on a new copy of that status (just like +blue[] would): !token-mod --set statusmarkers|!blue[] And using ! with a [] status and an index will toggle that index of the status on. &nbsp;Note that toggling status indexes that are higher than a set status will cause it to fill the next lowest slot. !token-mod --set statusmarkers|!blue[3] Executing this over and over on an empty token will add 1 blue dot each time until there are 3, then subsequently toggle the 3rd one on and off on each execution. Update v0.8.33 &nbsp;-- Fixed bug where specifying a character_id with --ids while having a token selected that represented that character would cause a double adjustment. (Thanks&nbsp; Dustin C. ) Update v0.8.32 &nbsp;-- Fixed crash for empty auras (and other places that could take a number or empty). &nbsp;Additionally, I've added error handling to prevent future crashes and make crash resolution easier. &nbsp;If a command would have caused a crash, it will now instead output this message as a whisper to the person who executed the command: The block at the bottom can be copied and pasted into a PM to me (link text goes to my profile). &nbsp;It contains the details of the message that was passed to TokenMod, as well as the callstack that crashed. &nbsp;Those are the two bits of information that I need to track down exactly what happened and fix it. With this new error handling, it won't crash the API and interrupt the game should there be a problem. &nbsp;Let me know if I can make any improvements to this. &nbsp;I have some ideas that will make it much nicer in the future and even &nbsp;allow other script authors to take advantage of it easily. Update v0.8.31 &nbsp;-- Fixed bug in multiply and divide logic. (Thanks&nbsp; Craven . ,&nbsp; keithcurtis ,&nbsp; Gold and others...) Update v0.8.30 -- Fixed bug in who determination in showHelp(). (Thanks BGB) Update v0.8.29 &nbsp;-- Fixed bug in who determination in showHelp(). (Thanks&nbsp; Arno ) Update v0.8.28 &nbsp;-- Added support for multiply (*) and divide (/) relative change options. &nbsp;Now you can do something like this: !token-mod --set height|*2 width|*2 To double the size of your token, or this: !token-mod --set height|/2 width|/2 To shrink it back down again. Update v0.8.27 -- Fixed method for getting the display name of the current player so it won't crash when other api scripts execute API commands with sendChat() (Thanks Sky ). Update v0.8.26 &nbsp;-- Added the ability to specify character IDs to --ids and affect all tokens representing that character. (Thanks&nbsp; Hacchinya ) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-- Added logic to link a bar to a sheet attribute if an actually Attribute Object doesn't exist. &nbsp;This has one quirk in that it won't set the values of the bars until something happens to cause Roll20 to review the token. &nbsp;Setting the token as a Default Token and dragging it back out causes this to happen, as does updating something that the set attr uses in a calculation (dexterity when it's a part of the initiative_bonus formula for example). &nbsp;You can also set the initial value with --bar1_value|@{selected|attribute} if you're only doing a single character. &nbsp;(Thanks&nbsp; Arno ) Update v0.8.25 &nbsp;-- Fixed bug with defaulttoken where it didn't set correctly on the character. (Thanks&nbsp; Mike B. ) Update v0.8.24 -- Added the ability to set the defaulttoken on a character. &nbsp;You must set the represents of the token to a character before using defaulttoken, but it works just as you'd expected: !token-mod --set defaulttoken You can of course chain this with other set commands: !token-mod {{ --set represents|@{bob|character_id} bar1_link|hp bar2_link|speed bar3_link|ac controlledby|tom|sally|nancy statusmarkers|blue:3|red:[[1d6]] defaulttoken }} Be sure to set the default token after all the settings you want preserved. &nbsp;For example, if you set bar3_link after, it won't be set when you drag the token out later. &nbsp;(Thanks Jakob!) Update v0.8.23 &nbsp;-- Added the ability to copy the controlledby from a token or character. &nbsp;You'll want to be explicit with your operators to avoid problems. &nbsp;If a token is representing a character, it will copy the character's controlled by instead. !token-mod --set controlledby|=@{target|token_id} Append the controllers from a token: !token-mod --set controlledby|+@{target|token_id} Update v0.8.22 &nbsp;-- Added support for setting the image on a token. &nbsp;This needs to be in a player library or no change will be made: !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> Added support for setting the controlledby property. &nbsp;You can provide either a Player ID (Game Unique), Roll20 ID Number (Player Unique), or Player Name Match (can match multiple players). &nbsp;There are 3 operations: +, -, = (default). You can use ' or " around arguments to make things less confusing. &nbsp;The help is very explicit, take a look there for more details. &nbsp;Here are a few examples (more in the help): Just players with bob in the name: !token-mod --set controlledby|bob Remove player with ID -JK123adf234 (note the quotes): !token-mod --set controlledby|-"-JK123adf234" Add susan and tommy to the list: !token-mod --set controlledby|+susan|+tommy All the players with k in their name but not karen: !token-mod --set controlledby|k|-karen No one: !token-mod --set controlledby| Everyone: !token-mod --set controlledby|all Plays well with represents. &nbsp;If a token represents a character, the character's controlledby is adjusted instead of the token's. &nbsp;If you are setting a controlledby and represents in the same command, it will use the character you're setting (or the token if you are removing a controlledby, useful for divorcing one off tokens from their character and granting token control in one fell swoop!). !token-mod {{ --set represents|rook controlledby|="bob 'tacos' slayer" }} Added support for API Notifications when a token is changed. &nbsp;Pass your function to TokenMod.ObserveTokenChange(), it will be passed the token and a prev object directly after each token is changed. &nbsp;Example code: on('ready',function(){ if('undefined' !== typeof TokenMod &amp;&amp; TokenMod.ObserveTokenChange){ TokenMod.ObserveTokenChange(function(obj,prev){ if(obj.get('statusmarkers') !== prev.statusmarkers){ sendChat('Observer Token Change','Token: '+obj.get('name')+' has changed status markers!'); } }); } }); Changed the way tokens are handled from --ids and selected such that there aren't duplicates if a token is both selected and passed to --ids. Update v0.8.18 -- Fixed crash bug on --help from recent changes to sendChat(). (Thanks RMcD &amp; andrew M. ) Update v0.8.17 -- Added support for blanking represents by using --set represents| (Thanks Vince ) Update v0.8.16 -- Added --order for pushing tokens to the front or back (Thanks Nosaj !): !token-mod --order tofrontFor to front, use one of: tofront, front, f, top For to back, use one of: toback, back, b, bottom Update v0.8.15 -- Fixed the bug preventing setting some properties to blank. (Thanks Jacob !) Update v0.8.14 -- Fixed the bug causing a crash for empty arguments. (Thanks Gozer the Gozerian !) Update v0.8.13 -- Added # as an alternative to | in commands. This makes some macros easier to write. !token-mod --set ?{Feature|Dead, statusmarkers#dead|Red 3, statusmarkers#red:3} Update v0.8.12 -- Fixed explicit set with = for number and numberText fields. (Thanks again, Ziechael!) Update v0.8.11 -- You can now preface a + or - number with an = to explicitly set the field to that value (Thanks Ziechael!) !token-mod --set light_radius|=-10 Update v0.8.10 -- You can now set light_losangle and light_angle to be 360 degrees (Thanks Vince!). !token-mod --set light_losangle|360 Added a syntax to allow incrementing and decrementing status markers without adding statuses on other tokens. Also removes the status marker when the number reaches 0. (Thanks DK Heinrich!). !token-mod --set statusmarkers|?red:-1 Update v0.8.9 -- Added the argument --ignore-selected which allows writing macros that won't change any tokens that happen to be selected. !token-mod --ignore-selected --set statusmarkers|red:3 --ids -Jny0PfbtztLnCQv4M5y This is most useful when you are using hidden tokens as a backing store for state information (time, rounds, money, etc). (Thanks OldSchoolChris!) Update v0.8.8 -- Added expansion of Rollable Tables. You can now specify rollable tables in places you would use text: !token-mod --set name|"[[ 1t[ClueNames] ]]" Be sure to put " " around the call if you have multi word results. (Thanks Pat!) Update v0.8.7 -- Fixed crash when attempting to affect graphic tokens with bar*_reset operations. (Thanks RMcD!) Update v0.8.6 -- Added bar1_reset, bar2_reset, bar3_reset. You can use them to set a bar back to it's max value while selecting many tokens: !token-mod --set bar2_reset| This will individually set each token's bar2_value to whatever it's bar2_max is. The | is still required because of the way the parser is written, but I might be able to remove that later. Hope that helps! Cheers! (Based on this discussion , thanks RMcD!) Update v0.8.5 -- Bugfix for empty list of statuses. Update v0.8.4 -- Bugfix against an undefined statusmarkers return. Update v0.8.3 -- Fixed some log message detritus. Update v0.8.2 -- Added multiple status markers. I haven't updated the help for it yet, but basically, anything that works for a single status works for one with an index. The first command here sets the blue status marker on with a number of 1. The second line adds a second blue status marker and sets it's value to 2: !token-mod --set statusmarkers|blue:1 !token-mod --set statusmarkers|blue[2]:2 You can use an empty set of brackets to add a new marker: !token-mod --set statusmarkers|blue:1|blue[2]:2|blue[]:3 Just like other status operations, you can add all of these at once: !token-mod --set statusmarkers|blue:1|blue[2]:2|blue[]:3 Markers are indexed from 1 starting at the left most marker of a particular type. New markers are added to the right, so multiple markers can be interspersed as you like. Update v0.8.1 -- Added support for Multi-line commands via {{ }}, light_multiplier, startup version logging, and config API Button. You can now use the multiline syntax for your TokenMod commands: !token-mod {{ --set light_radius|40 light_dimradius|0 light_multiplier|1.5 layer|objects --flip showname --off light_otherplayers --set bar1_value|25 bar2_value|Foe --ids @{target|target 1|token_id} @{target|target 2|token_id} @{target|target 3|token_id} }} An API startup, it will now log out the version number and last update date: "-=&gt; TokenMod v0.8.1 &lt;=- [Sun Mar 29 2015 00:40:56 GMT-0500 (CDT)]" This will get updated as I make further changes (coming soon to all my scripts!) The Help menu is reorganized a bit, and there is now a toggle button for turning on/off Players Can IDs. Update v0.7 -- Added support for unlinking bars by passing an empty Attribute Name. (Thanks Ari K.!) Update v0.6 -- Switched to git and pushed into the Roll20 Official repo as well. Update v0.53 -- You can now toggle status markers on and off by prefacing them with the ! symbol. This will add the Rook piece if it isn't there, but remove it if it is: !token-mod --set statusmarkers|!white-tower Adding with a number will set the number if the status was not present, so this would add blue with a value of 3 if it wasn't already there, but clear it if it was: !token-mod --set statusmarkers|!blue:3 Adding relative numbers is less useful since they would always be operating on 0 (if the status wasn't there) or not being applied (because the status is being removed if it was there already), but they don't cause an error. I also expanded the help to show --ids and how to use it for multiple token ids (Thanks John C.), as well as cleaning up a few other points. Update v0.52 -- Setting Number and Number or Blank can now be decimal. (Thanks Black Falcon) Update v0.51 -- Setting represents now supports character names instead of just character_id. You can use the full name (quoted if it contains spaces) or just a partial name that is unique among your characters. It is not case sensitive, so Max = max = MaX = MAX. Update v0.5 -- Added delta changes to all reasonable number fields. You can now specify +3 or -2 instead of just a number, even on status numbers: !token-mod --set statusmarkers|blue:-1 bar1_value|+3 This can be used on any field that is one of: Number, Number or Blank, Degrees, Text, Status Status fields will be bound between 0 or 9, other fields will not be bound. Also added the ability to set the represents for a token. You need only specify the character_id, probably with @{&lt;character name&gt;|character_id}: !token-mod --set represents|@{Bob|character_id} Note that this will clear out any links that bars have currently... So I've also added setting links for the bars, using the fields bar1_link, bar2_link, bar3_link. You need to specify the name of an attribute on the character the token represents. If you're specifying these in the same command as represents, be sure they are after: !token-mod --set represents|@{Bob|character_id} bar1_link|npc_HP bar2_link|npc_ac bar3_link|npc_temp_HP One final caution: There seems to be a bug with updating a token bar via the API when it is tied to an attribute, such that other tokens that are tied to the same attribute do not get updated. Be sure to leave a comment if you experience that, particularly if you can narrow down the case. Update v0.4 -- Added --config command for setting configurations. Currently the only config option is players-can-ids which allows players to use the --ids command to target tokens they don't control. Updated documentation to add bar1, bar2, bar3 meta properties, added notes about support for inline rolls in --set. Turn on players ability to use --ids with: !token-mod --config players-can-ids|on Play slots with this: !token-mod --set statusmarkers|red:[[1d9]]|green:[[1d9]]|blue:[[1d9]] Set hit points with this (sets both bar2_value and bar2_max to the result of the expression): !token-mod --set bar2|[[3d8+4]] Update v0.32 -- Added expansion of inline rolls and the Meta-Properties bar1, bar2, bar3 which set the _value and _max values to whatever is supplied. (Thanks for the suggestion Leo!) Update v0.31 -- Minor update to fix the issue with HTML special entities. Update v0.3 -- Fixed a bug with --ids (Thanks again James!) Update v0.2 -- Fixed a bug with colors, made the help work for non-GMs. (Thanks James!) This script lets you change just about any property of a token from a macro or the chat (Thanks GenKitty for the idea!). You can only change tokens you control (enforced by the ability to select them), unless you are the GM, in which case you can specify token_ids with the --ids command. The same operation is applied to all selected tokens, so it makes batch changes fast and easy. Commands !token-mod -- This is the interface command, with the following options: --help -- Displays the help script. --on &lt;arguments&gt; -- Toggles supplied boolean arguments to on. --off &lt;arguments -- Toggles supplied boolean arguments to off. --flip &lt;arguments&gt; -- Toggles supplied boolean arguments to their alternate state. On becomes off, off becomes on. --set &lt;arguments|values&gt; -- Sets an property to the supplied value. The help is extensive, but I'll hit the highlights below. --ids &lt;arguments&gt; -- The GM can supply a list of token_ids, probably with @{target|1|token_id}, etc. Details for --set Mostly, properties should work like you expect. If it's a color, it takes a color, if it's a number, it takes a number. Any argument with an invalid value is ignored. Here's a few examples that should make things clearer. Turning on name plates for all selected tokens: !token-mod --on showname Moving selected tokens to the gmlayer: !token-mod --set layer|gmlayer Turning on aura1 for players, setting it's radius to 35, setting it's color to blue: !token-mod --on showplayers_aura1 --set aura1_radius|35 aura1_color|0000ff Setting up 5e style darkvision, moving to the objects layer, flipping the setting on show names, set bar1 to 25, set bar2 to 'Foe': !token-mod --set light_radius|40 light_dimradius|0 layer|objects --flip showname --off light_otherplayers --set bar1_value|25 bar2_value|Foe I've carefully ignored status markers until now. Status markers have a more complicated syntax to allow more flexibility. Multiple status markers can be set at the same time, this will add the blue, green, red, padlock, and broken-shield status markers. !token-mod --set statusmarkers|blue|green|red|padlock|broken-shield They can also take a number by appending it with a : separator to the end of each status name. (note that the number following the dead status is ignored, as it is special.) !token-mod --set statusmarkers|blue:0|green:3|red:9|padlock:7|broken-shield:8 Numbers are bound between 0 and 9. You can also remove status markers by prefacing them with a -. This will remove the blue and broken-shield status markers: !token-mod --set statusmarkers|-blue|-broken-shield If you want to completely clear all status markers when you set your new one, you can preface it with a =. Note that this will affect all previously applied status markers, even if you are applying them as part of this same set command. This will set only the red, green, and blue markers: !token-mod --set statusmarkers|=blue|green|red If you need to just remove all status markers, you can specify the same status marker twice, first with = and second with -: !token-mod --set statusmarkers|=blue|-blue Example using --ids and other things: !token-mod --set layer|objects aura1_radius|35 aura1_color|00ff00 tint_color|transparent --on showname --ids @{target|token_id} The help has grown large enough that posting it here is a bit crazy. &nbsp;See the in game help or the help on the API page for more details: !token-mod --help GitHub: <a href="https://github.com/shdwjk/Roll20API/blob/master/TokenMod/TokenMod.js" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/TokenMod/TokenMod.js</a> Support my work on If you use my scripts, want to contribute, and have the spare bucks to do so , go right ahead. However, please don't feel like you must contribute just to use them! I'd much rather have happy Roll20 users armed with my scripts than people not using them out of some sense of shame. Use them and be happy, completely guilt-free! Disclaimer: This Patreon campaign is not affiliated with Roll20; as such, contributions are voluntary and Roll20 cannot provide support or refunds for contributions.
Awesome new additions to this utterly awesome script! If a token represents a character, the character's controlledby is adjusted instead of the token's. I see some unicorn magic is starting to get sprinkled into the mix! :D
1478733143
The Aaron
Pro
API Scripter
I know, seriously. &nbsp; Probably I should just come out with Mod script that just does all of it. :)
How about just a script that does everything? Would solve those pesky concatenation issues!
1478733656
The Aaron
Pro
API Scripter
!do all&nbsp;the things
1478809272
The Aaron
Pro
API Scripter
Update v0.8.23 -- Added the ability to copy the controlledby from a token or character. You'll want to be explicit with your operators to avoid problems. If a token is representing a character, it will copy the character's controlled by instead. !token-mod --set controlledby|=@{target|token_id} Append the controllers from a token: !token-mod --set controlledby|+@{target|token_id}
&nbsp;Hey Aaron! Great work as usual, i grow more and more amazed by the work you put into these scripts. I have a question though. I'm trying to write a macro that will first confirm whether an attack hit while comparing a d100 roll to a certain threshold (usually an accuracy attribute subtracted by the targets evasion attribute). If successful I want it to apply damage automatically deducting from the targets HP attribute (subtracted by armor or elemental resistances). Is there a way to do so this using this script?
1479149620
The Aaron
Pro
API Scripter
Yes. &nbsp;If players would be running this attack (and thus, this script), you'd need to enable "players can --IDs". &nbsp;It's the only config option, so just run the help and hit the button if it says it's OFF currently: !token-mod --help As to the damage command, you'd follow Brian's suggestion to get a value of 0 or 1 using &gt; as a comparison and use something like: !token-md --set bar1_current|[[ @{target|defender|bar1_current} - ([[ &lt;formula for a successful hit: 0 or 1&gt; ]]* [[ &lt;formula for damage done&gt; ]] ]] --ids @{target|defender|token_id} So the idea is that you set the target's bar (I used bar1) to the current value minus any damage done. &nbsp;If you need to cap it at 0, you can do some clever things with { &lt;value&gt;, 0d0}kh1 and the like. &nbsp;The same applies to healing. Let me know if you have any issues getting that to work. &nbsp;I could likely write you a little one-off snippet to do just what you're after (actually, I'm writing one right now that would likely work...).
That might be super helpful. I'm very code at modifying code/scripts but not so good at writing them myself. If nothing else it would give me something to go off of.
1479151858
The Aaron
Pro
API Scripter
cool. &nbsp;I'll link it here when I've finished it.
Wonderful! Thanks again :)
1479166639
The Aaron
Pro
API Scripter
Here's that related script, which I call ApplyChange: &nbsp; <a href="https://app.roll20.net/forum/permalink/4246882/" rel="nofollow">https://app.roll20.net/forum/permalink/4246882/</a>
Hmm... This seems to work very well for applying damage straight up. As far as knowing whether to apply it or not though, was that worked into this script at all?
1479171109
The Aaron
Pro
API Scripter
It has some decision points based on tagging and statuses. But you could definitely do the same multiplication trick to make the damage 0.&nbsp; It would definitely be possible to put other matchers in or use the tag to adjust the damage. &nbsp; Let's take discussion to that thread.&nbsp;
1479191536

Edited 1479191664
Kiyomi N.
Sheet Author
Which thread is that? I posted in specific use. Automatically determine hit, remove Damage/MP
1479210197
The Aaron
Pro
API Scripter
The one for that ApplyChange script:&nbsp; <a href="https://app.roll20.net/forum/permalink/4246882/" rel="nofollow">https://app.roll20.net/forum/permalink/4246882/</a> I added some more things to it that should help with what you want to do.&nbsp;
Is it possible to unlink bars with this? so example I want to create x number of mooks but i want them to link to a single sheet for rolling purposes. But I need to be able to edit hp individually so i'd like to have a macro to change bar 1, 2, and 3 to none. Is this something that can be done. I could just be missing the right command.
1479423202

Edited 1479423429
Scott W. said: Is it possible to unlink bars with this? Yup; this will unlink all three bars: !token-mod --set bar1_link| bar2_link| bar3_link|
Thank you!
So how do I use this in my game??&nbsp; I fdon't know anything about scripting API's... all I did was search for something that could automate Aura color changes and it led me here. I figured out how to install the script... but how do I use it? What's the interface? Where do I tell it to do something?&nbsp;
I'm helping out&nbsp; Enrique in another thread , in case anyone else is interested.
1482631483
The Aaron
Pro
API Scripter
The in game help should tell you how to do everything with it. Once it's installed, type this as a chat message: !token-mod --help
1482631698
The Aaron
Pro
API Scripter
Here's an example that includes setting the aura color on aura 1: !token-mod --set layer|objects aura1_radius|35 aura1_color|00ff00 tint_color|transparent --on showname --ids @{target|token_id}
1485219365

Edited 1485219516
Elena S.
Sheet Author
Here's an example of one of the macros I have so my players can quickly turn their auras on for short and medium ranges. Currently it pulls the weapon name and range information from the character sheet to display in a query which then posts a message in chat with the relevant weapon information. The problem with this approach is that when the macro gets to the API calls to turn on and set the aura radius, they currently have to type in the ranges manually. /w gm &{template:default}{{name=@{selected|token_name} is activating auras for Short and Medium ranges using a ?{Weapon being fired?| @{selected|weaponname} (@{selected|range})| @{selected|repeating_weapons_$0_weaponname1} (@{selected|repeating_weapons_$0_range1})| @{selected|repeating_weapons_$1_weaponname1} (@{selected|repeating_weapons_$1_range1})| @{selected|repeating_weapons_$2_weaponname1} (@{selected|repeating_weapons_$2_range1})}.}} !token-mod {{ --on aura1_square aura2_square --set aura1_radius|?{Distance for Short Range Aura?|10} aura2_radius|?{Distance for Medium Range Aura?|20} }} Is there a way to have TokenMod pull an attribute from an associated character sheet, parse the information and return multiple variables then apply the returned numbers to the aura radius token properties? (specifically I'm thinking of range info from the repeating weapons Fieldset on 2ed AD&D character sheet) For instance if they selected a "Javelin (10/20/40)" from the query, the script would grab (10/20/40) parse that into separate variables rngS = 10, rngM = 20, rngL = 40 and then use those variables as values. Or possibly even pull the range info from the chat message and parse that? I imagine the token-mod call of the macro it looking something like this: !token-mod {{ --on aura1_square aura2_square --set aura1_radius|rngS aura2_radius|rngM }} Do I need to customize TokenMod to do this, or would I need a seperate script which TokenMod can interact with? And I just gotta say.... seriously.... roll20 should have 3 bloody auras available on tokens!
1485219960
The Aaron
Pro
API Scripter
There isn't a way to do that in TokenMod currently I'm afraid. &nbsp;That's special purpose enough, I'd probably write a one off script to do that instead of modifying TokenMod to do it. Of course, if you WANT to modify it, you could certainly add it. I'd probably approach that as a separate script that creates invisible follower tokens whose auras show the various radi. &nbsp;You wouldn't give the players control of them, so they wouldn't interfere with anything, and you could still let the players do what they want to with their own auras.
Okay, you're speaking greek with follower tokens.... Java is not something I'm comfortable with. html and css: Yes, in a fairly basic way. Java: No, I get lost pretty dang quickly. I don't even know how to approach creating a function that would be able to parse the ranges info into separate variables. All of my programming experience is based on one computer class in junior high (long enough ago that I don't want to admit how many years), and fiddling with stuff for countless hours until I bludgeon the code into doing what I want (mostly with web pages).
1485223968
The Aaron
Pro
API Scripter
Java SCRIPT! &nbsp; It's very different from Java. =D &nbsp;(Really, it's ECMAScript, but nobody calls it that...) With followers, I just mean a token the API creates and keeps at the same position as another token. &nbsp;You can see it in action with Bump or Torch (with the flicker command). Here is a function that will return an array of the ranges given a string of that form: var getRanges = function(desc){ &nbsp; return _.chain(desc.match(/^.*\(\s*(\d+)\s*\/\s*(\d+)\s*\/\s*(\d+)\s*\).*$/)) &nbsp; &nbsp; .rest() &nbsp; &nbsp; .map((n)=&gt;parseInt(n,10)) &nbsp; &nbsp; .value(); }; If you were to pass that your javelin line, you'd get: [10, 20, 30]
1485227217

Edited 1485227576
Elena S.
Sheet Author
Okay, I think I understand how that's working,. At least how the function turns the information passed into the array. Not how to pass it to the function though. Would the query generating the string with the relevant weapon and ranges be part of an API call instead of part of the chat output of the macro? Possibly storing the string selected by the player as a variable to return to chat after the range portion had been parsed into the array, and then have another command to output to chat? How would that function be called so that it returns the appropriate entries in the array as the values for the aura#_radius &lt;key&gt;|&lt;value&gt; pairs? By array index possibly? Would I also want an error control in case the player selected a melee weapon with only one number in the range field? Not sure if that would break something or not.
1485229062
The Aaron
Pro
API Scripter
So, you'd have to call that function in the API somewhere. &nbsp;I'd picture doing this as part of a separate script, something like (pseudocode): // on some command like !show-ranges // get all selected tokens (msg.selected has the ids, use getObj() to get the tokens) // get all characters represented by selected tokens (use getObj() with the token.get('represents') id) // get all attributes for the currently equipped weapon range (use getObj() with the id of the characters and the name of the attribute) // get ranges from the attributes with getRanges(attr.get('value') // set auras on selected tokens that had ranges. (use obj.set() on the tokens you already have). That's all reasonably straightforward. &nbsp;The devil is in the details, of course.
You have officially completely lost me! Maybe it looks straightforward to you....
1485232799
The Aaron
Pro
API Scripter
Yeah, sorry... I don't even see the code anymore...&nbsp; Try this: on('ready',function(){ &nbsp; &nbsp; "use strict"; &nbsp; &nbsp; var aura1Color='#ff0000', &nbsp; &nbsp; &nbsp; &nbsp; aura2Color='#0000ff', &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; getRanges = function(desc){ &nbsp; &nbsp; &nbsp; return _.chain((desc||'').match(/^.*\(\s*(\d+)\s*\/\s*(\d+)\s*\/\s*(\d+)\s*\).*$/)) &nbsp; &nbsp; &nbsp; &nbsp; .rest() &nbsp; &nbsp; &nbsp; &nbsp; .map((n)=&gt;parseInt(n,10)) &nbsp; &nbsp; &nbsp; &nbsp; .value(); &nbsp; &nbsp; }, &nbsp; &nbsp; bound = (v,l,h) =&gt; Math.min(h,Math.max(l,v)); &nbsp; &nbsp; on('chat:message',function(msg){ &nbsp; &nbsp; &nbsp; &nbsp; if('api' === msg.type && msg.content.match(/^!aura-range\b/) ){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let args=_.rest(msg.content.split(/\s+/)), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; attrName=(args.shift()||''), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aura1Index = bound( (args.shift()||0), 0, 2), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aura2Index = bound( (args.shift()||1), 0, 2); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _.chain(msg.selected) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .pluck('_id') &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .map( (id) =&gt; getObj('graphic',id) ) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .reject(_.isUndefined) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .map( (t) =&gt; {return {token:t, character:getObj('character',t.get('represents'))};} ) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .reject( (o)=&gt;_.isUndefined(o.character)) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .map( (o) =&gt; { o.attribute = findObjs({ type:'attribute', characterid:o.character.id, name: attrName})[0]; return o; }) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .reject( (o)=&gt;_.isUndefined(o.attribute)) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .map( (o) =&gt; { o.ranges = getRanges(o.attribute.get('current')); return o; }) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .each( (o) =&gt; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; o.token.set({ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aura1_color: aura1Color, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aura1_radius: (o.ranges[aura1Index]||0), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aura2_color: aura2Color, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aura2_radius: (o.ranges[aura2Index]||0), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; }); }); Command syntax: !aura-range &lt;attribute name&gt; [aura 1 index] [aura 2 index] Example: !aura-range selectedWeapon Given your example of "Javelin (10/20/30)", this will set the auras of 10 and 20 for the selected tokens (assuming they had that text in the attribute selectedWeapon). !aura-range selectedWeapon 2 0 Will set Aura 1 (red) to 30, and aura 2 (blue) to 10. In the case where the attribute doesn't exist, or doesn't look like that javelin example, or has fewer numbers, it will set the aura radius to 0. Happy Rolling!
Okay, so here's a little monkey-wrench to toss at you... My bad for not making this clear in my original question. The sample macro I posted with my initial question was one of a branch set, which cascades down from a single token action to allow players to: set auras for Short/Medium Range set auras for Medium/Long Range set a single aura for a Spell or Ability make their auras visible to other players or to turn their auras off (which also resets the showplayers_aura#) keys to off The "Spell/Ability Aura", "Make Aura Visibile", and "Auras-Off" all behave exactly how I want them to with just TokenMod. It's just the ones for missile weapon ranges that I wanted to improve. (which is of course why I can't for the life of me figure out why roll20 only as 2 auras on tokens, I've never played a RPG that only used 2 range categories.) So how do I address the companion macro in the branch set intended for Medium and Long ranges? (guessing this makes the script quite a bit more complicated...)
1485235585

Edited 1485235685
The Aaron
Pro
API Scripter
Possibly not a lot more complicated, but I see the quandary. Could you post the full macro you're using? Regarding auras, they probably didn't foresee the uses people would put them to. :) (also, expect a bit of latency... I'm already in bed so will likely fall asleep before the next post...)
1485236330

Edited 1485236507
Elena S.
Sheet Author
NVM, I figured out how to call different indexes in the array for medium/long range... what I am not catching on to is how to call the desired weapon and range info into the function No worries, I didn't really expect you to do nearly as much as you have all in one evening!
1485237865
The Aaron
Pro
API Scripter
It would have to be in an attribute you could pass the name of. So, if @{selected|weaponAttrName} prints it in chat, you would pass weaponAttrName to the script.&nbsp;
Okay, I've been playing with it a bit. what I'm running in to is that the script is set up to have a single attribute passed to it, not a string from chat including both the weapon name attribute and the range attribute enclosed in (). Which is based on how the text output of my current macro displays. I tried fiddling with just sending the script the range attribute and it gave me a big old error. I then tried editing the range attribute which I was sending to the script, writing it as (20/40/80) and it worked fine. so it seems that the script is relying on the parentheses around the ranges. If I can just pass it the value of the range attribute without having to have the parenthases that would be spectacular. I'll fiddle with it and see if I can figure out what to tweak myself and post the result if I get it (or post a gibbering mess if I don't) Thanks for all the help!
Okay, I give up... I need help sorting this out! I can't for the life of me find where to tweak the code to remove the requirement for the putting the parentheses in the attribute that is being called to the script, and I'm getting some other unexpected behavior when calling attributes from repeating fieldsets. So as the script stands I can pass it an attrName coded into the character sheet or added as a custom attribute and as long as the contents of that attribute is written with the format (#/#/#) the script behaves as expected and turns on the auras and calls the array indexes specified in the API command. Example 1: Passing the script an attribute from the related sheet designating array indexes 1 and 2 !aura-range range 1 2 This accurately sets the aura ranges to Medium and Long based on the array indexes listed in the command, but only if the range attribute is written as (50/100/210), when the range attribute is written as 50/100/210 &nbsp;(which is how all of my ranges are annotated on dozens of character sheets) the script fails and crashes my sandbox with a big nasty error message. Example 2: Passing the script an attribute from the related sheet designating array indexes 0 and 1 !aura-range range 0 1 This accurately sets the aura ranges to Short and Medium, with the same quirks as above regarding the syntax in the range attribute. Example 3: Passing the script an attribute from a repeating fieldset on the sheet. (the attribute value contains the syntax which was working for the fixed sheet attribute) !aura-range repeating_weapons_$0_range1 0 1 Absolutely nothing happens when I pass the script this attribute. What the heck? No errors in the log, but it doesn't do anything either.... Now I'm really confused, is the syntax for calling an attribute from a repeating fieldset different in the API than it is when calling one from a macro? If I can't call ranges from repeating fields this whole train gets derailed pretty fast... If that hurdle can be jumped, I have one other request. Could it be set up so that the colors defined in the variables at the beginning of the script be placed in an array with 4 colors and when the aura colors are set use the same array index calls as the range array indexes? That way when a call is made to display auras for different ranges the aura colors would be tied to the range being displayed. Thinking 4 colors in the array since specialists get the bonus range category of point blank. .....Thinking at this point this might need to be broken off into it's own thread....
Oh, and for verification purposes, yes putting @{selected|repeating_weapons_$0_range1} into chat does return the attribute value from the repeating fieldset
1485264522
The Aaron
Pro
API Scripter
Yeah, let's break this off to another thread. =D &nbsp; All of the above can be done, no worries.
Okay, new thread for the RangeAuras script is&nbsp; HERE!
1485288462
The Aaron
Pro
API Scripter
Thx!
I'm sure this is a dumb question, but I didn't find the answer on quick Google searches for your name and this API. Can I use this script to switch between tokens controlled by the same player, in order to represent shapeshifting? Specifically, I have a character who has five different shapes he uses on a regular basis, each with different attributes and abilities. My bad-at-scripting solution was to create a different sheet for each one, and have each sheet's individual token on the GM Layer. When the character shifts form, I take a few seconds to swap the previous token into the GM Layer and bring the new one to the Token Layer, where the player takes over control again. I have other PCs in the game with similar power sets, although not to the same extent (one has two forms, the other has three). While my kludge works, I feel certain there's got to be an easier way to do this with with TokenMod. Any advice would be appreciated.
1485646783
The Aaron
Pro
API Scripter
You can, with one caveat.&nbsp; This will switch the selected token's image: !token-mod --set imgsrc|&lt;some URL&gt; the "some URL" must be the URL of an image in a user library on Roll20. If you want to use marketplace content, you will need to download it and re-upload to your user library.&nbsp; You can then setup aacro with all the images like this: !token-mod --set imgsrc|?{Form|Human,http:...|Bear,http:...|Walrus,http:...}
Awesome. Is there a way to direct those tokens to different sheets? My other plan was to change the common player macros so that they could input their own modifiers instead of calling to sheets, which might just be less work for me in the long run.
1485664564
The Aaron
Pro
API Scripter
Yup! &nbsp;You can use --set represents to set the character: !token-mod --set represents|"Billy the squid" It tries to be smart about matching the character, so you just need the smallest unique part of the name, so you could use "Billy" or "thesquid" (spaces are ignored) or even just "q" if no other name had a q in it.&nbsp; You may also want to set the bar links (and multi line is easier to read): !token-mod {{ --set represents|billy bar1_link|ac bar2_link|speed bar3_link|hp }}
That is awesome. Thanks so much.
1485666218
The Aaron
Pro
API Scripter
Yup! &nbsp;Pretty much, if you can do it through the token dialog, you can do it with TokenMod. Be sure and read the help: !token-mod --help And feel free to ask more questions here. :) Happy Rolling!
O Grand and Glorious Scriptomancer! I have been using Tokenmod for quite awhile now primarily for status marker manipulation. But now I'm looking at the other neat things it can do - like move a token to a specific location on the map. Is there a way to move a token one square (or more) over from it's current location? Does it know where the token is?
1486161276
The Aaron
Pro
API Scripter
It doesn't, but I've been thinking about that quite a bit. &nbsp;I should just add that real quick...
1486162968
The Aaron
Pro
API Scripter
Nevermind, it DOES support that. Here is a knight move from chess: !token-mod --set top|+70 left|+140
1486163107
The Aaron
Pro
API Scripter
Works for: left, top, width, height, rotation, light_angle, light_losangle, light_radius, light_dimradius,light_multiplier, aura1_radius, aura2_radius, bar1_value, bar2_value, bar3_value, bar1_max, bar2_max, bar3_max, bar1, bar2, bar3, name, and status marker numbers.