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.

Hi all, first time poster. I'm trying to set up a macro to have all tokens on the current page with the same name ("Troll") regenerate 10 hp, up to hp_max. I tried the following macro, but it adds 10 to one token's hp and copies that value to all the other tokens named "Troll". What I want is to have 10 added to each individual troll's hp. !token-mod {{ --ids @{Troll|character_id} --set bar3_value|[[{@{selected|bar3|max},[[@{selected|bar3}+10]]}kl1]] --current-page }} Is there a way to do this with Token Mod?  I'm using the D&D 5E 2014 by Roll20 character sheet, if that matters, and bar3 as hp. Thanks!
1732836498
Andrew R.
Pro
Sheet Author
You’ll want to use the MetaScriptToolbox to get TokenMod to act on all the Troll tokens individually. 
Thanks for the suggestion, Andrew R. I actually found a simpler method: !token-mod --set bar3_value|+10! This adds 10 to all selected tokens properly, and the ! at the end constrains the result between 0 and hp_max.
1732918907
The Aaron
Roll20 Production Team
API Scripter
You should be able to apply that to your original command and get a command that heals all trolls on the page. !token-mod {{ --ids @{Troll|character_id} --set bar3_value|+10! --current-page }} You could combine this with OnMyTurn to have an "EndOfTurn" character with an ability that calls it whenever its turn comes up in the turn order.  If you do that, you should use: !token-mod {{ --ids @{Troll|character_id} --set bar3_value|+10! --active-pages }} --current-page will be the page of the player calling the command, but OnMyTurn is the API calling the command, so doesn't have a page, but --active-pages will be every page that has a player on it, which will generally be what you want.
Careful with OnMyTurn, because it will trigger at the start of every Troll’s turn, and the first time I used it, it applied the effect to every token of that character on every token’s turn, as opposed to just to that token on that token’s turn. ;-) 
Thanks for the help! The first script works perfectly, but I noticed that for the one using OnMyTurn only one troll on the page gets the additional hp. Any ideas? Thanks again!
1733081484

Edited 1733081713
Hello, For the first time, I'm having an issue with TokenMod. I have a small macro that's supposed to enable or disable the torches for my players' tokens, but at some point, it seems like everything crashes. The players end up with a black screen, even though vision is enabled and they are supposed to emit light. Here is my code : !token-mod {{ --on emits_bright_light emits_low_light --set bright_light_distance|6 low_light_distance|6 }} !token-mod {{ --off emits_bright_light emits_low_light --set bright_light_distance|0 low_light_distance|0 }} I’m playing with Jumpgate with the core D&D system (2014).
1735926091
The Aaron
Roll20 Production Team
API Scripter
Sorry for the delay responding.  That looks like it should work.  I'll have to try and repro that.
1735960679
The Aaron
Roll20 Production Team
API Scripter
Update v0.8.80  - Added support for Beacon Sheets when linking bars, and updating bars linked to Beacon Computeds. This is a pretty transparent update, but for example, you can link a token's bar3 to the hp computed from the DnD 2024 sheet using: !token-mod --set bar3_link|hp You can then make updates to it using something like the following: !token-mod --set bar3_value|+30!
Yay! Definitely one of the more annoying things about having the players on the 2024 sheet while I use the 2014 sheet for the monsters is that many API scripts aren’t working on the players’ PCs. :-P Thank you for continuing work towards full compatibility for yours. :-)
1736006098
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Joe said: Yay! Definitely one of the more annoying things about having the players on the 2024 sheet while I use the 2014 sheet for the monsters is that many API scripts aren’t working on the players’ PCs. :-P Thank you for continuing work towards full compatibility for yours. :-) Hear! Hear!
I'm here to report a pretty grave bug/missing feature from the script TokenMod v0.8.74 going to copy and paste sections of the Help handout in game. You can set multiple of the same status marker with a bracket syntax. Copies of a status are indexed starting at 1 from left to right. Leaving brackets off will be the same as specifying index 1. Using empty brackets is the same as specifying an index 1 greater than the highest index in use. When setting a status at an index that doesn't exist (say, 8 when you only have 2 of that status) it will be appended to the right as the next index. When removing a status that doesn't exist, it will be ignored. Removing the empty bracket status will remove all statues of that type. Adding 2 blue status markers with the numbers 7 and 5 in a few different ways: !token-mod --set statusmarkers|blue:7|blue[]:5 This seems to work as normal. !token-mod --set statusmarkers|blue[]:7|blue[]:5 This as well. !token-mod --set statusmarkers|blue1:7|blue2:5 This, however, has no effect. No error message, the command simply does not function. This means that there is no way to affect additional copies of a marker as trying to use the bracket index parameter just adds more copies of the marker. !token-mod --set statusmarkers|-blue2 Likewise, this command does nothing. !token-mod --set statusmarkers|-blue[] This command does not remove all blue status markers as intended but instead removes only 1 status marker of index n+1. I'm using other api scripts and have not updated tokenmod to not break anything. These commands have been tested without the other scripts active. Are these just discontinued features? Has a roll20 update broken this functionality? Thank you for your attention.
1736437691
The Aaron
Roll20 Production Team
API Scripter
Multiple status markers is broken on Jumpgate. It is an emergent feature in classic and I'm hoping it's one we can get retained in Jumpgate. I've brought it up to the devs, I'll bring it up again. 
My repeated broken trust of the Roll20 devs' ability to keep the app working correctly has naturally led me to put off jumpgate for as long as possible; i still use the original editor for all my games.
Hello.  Trying to write / update token mod to set a variety of vision statuses on player tokens with a single button click through menu's.  Actually, have a whole menu of GM scripts, but the relevant section is the "lights" one below.  Seems like many people have tried using token mod to manage lighting and vision, but I didn't find my error when trolling through ALL 48 PAGES of the community forum's (they really need to add a search function, this is stupid long, which is good, it's popular.  But mind numbing trying to find the one thing you are looking for needle in the haystack.  Honestly I didn't get close to making it through all 48 pages before I gave up).       The objective is to be able to hit my GM Macro's master macro (the red button above), which pulls up my list of buttons that calls all my "GM Macros" in chat (I have quite a few more for other stuff, but the lighting macros are the issue at the moment), then select what I want to do (Give a player a torch), then select the player token and apply the modifier (lighting for a torch in this case).  My test token mod script for a torch looks like: !token-mod {{ --ids @{target|1|token_id} --on   bright_vision   emits_bright   emits_low   has_limit_field_of_vision --off   has_directional_bright_light --set   limit_field_of_vision_total|?{field of vision degrees|120}   bright_light_distance|?{Bright light distance|2}   low_light_distance|?{Low light distance|3}   directional_bright_light_total|360 }} My problem is, if I already have a token selected, it works just fine.  It askes me to select a target as expected and applies the desired vision properties.  Interestingly, if I do not have a token selected and I copy / paste the token mod script into the chat window, hit enter, it works just fine. If, however, I don't have a token selected before hitting the torch button, not only do I get the message above to choose a target.  I get the below in the chat window.   And after I select a token, nothing is applied to the token and my chat window is filled with this error message (it appears that the error message is repeating until the token mod errors out and "escapes".  I assume token mod has some kind of loop counter built in). Question:  Does Token Mod require that a token be selected before attempting to use it in a macro?  I didn't think so based on my reading, but if not, then I'm doing something very wrong.  Whatever it is, I can't seem to figure it out.  I am using jumpgate.  
1736599868
timmaugh
Pro
API Scripter
What other scripts do you have installed, Michael? This doesn't sound like a TokenMod issue. Perhaps there's another that is firing when it detects that you've sent a message through the chat.
1736602556
The Aaron
Roll20 Production Team
API Scripter
The issue is likely that the @{selected} or @{target} reference is fulfilled when the master macro is executed, not when the API Command Button is clicked. You need to escape the reference so it only gets evaluated when the button is clicked, not when it is created.  [do thing](!token-mod --set statusmarkers|!blue --ids @{target|token_id}
1736627463
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
There could also be other commands within the larger GM macro with the same issue.
Thank you @"The Aaron".  That did not make it work the way I wanted (allowing me to select a token after selecting the torch button), the opportunity to select a token doesn't even come up now.  But it did prevent the overflow error problem regardless of what I do.  Now it just states that there was no token selected.  Not quite the way I wanted it to work, but it works, and it doesn't error out.  I just have to select a token before hitting the torch button.  So, off to set all the properties actually the way I want them.  
keithcurtis said: There could also be other commands within the larger GM macro with the same issue. Yes, I suspect there would be.  I'm just writing them now, so we will figure that out as this goes.  The torch one was my test to get this idea working.  It will be the format I copy for the other lighting scripts.  We do a mix of games, so I was planning on adding ones for night vision goggles, and modern devices so I can use this one macro everywhere.  I wonder what happens if you move the token selection outside of the script call?  Does this work like old school coding (I learned Fortran 4 back in the day at college) where things are done in order from top to bottom, or if all these commands are sent to the Roll20 server all at once.  I.e., would this work.  I don't think so, I think Roll20 sends everything from the chat window (i.e. script calls and macros) to the Roll20 server to be dealt with all as a single text block to be resolved all at once. @{target|token_name} !token-mod {{ --on   bright_vision   blah blah blah token mod commands here }} Will have to try that tonight when I get back home.  Would that "pick a token" before attempting to run the script?  Hhhhmmmm
1736630568
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Yes, if you use the format [buttonName](~actionName) for an action on the same sheet, or  [buttonName](~sheetName|actionName)  for an action on  different sheet, they will not resolve until clicked. More syntax advice can be found here:  Chat Menu .
1736659481
timmaugh
Pro
API Scripter
We need to clarify something because things can get muddled pretty quickly. A token is "selected" when you click on it on the game board SEPARATE FROM a message. Selected tokens appear as with a box around them with handles for sizing (if they are selected individually), or with a box around multiple tokens (if more than one is selected). They are referred to with @{selected ...} syntax. "Targeted" tokens are only chosen as a part of a command line message. They are also designated by clicking, but they do not retain a box around them between messages. They are referred to with @{target...} syntax. Because of these differences, it doesn't help to refer to "clicking"on a token as a way of clarifying whether a token has been selected or is being targeted (both methods require a click). It doesn't help to refer to "selecting a target" if it isn't clear that the 2 terms are being used correctly. ...and I *am* confused by your post: the "no tokens selected" message only occurs when you use a @{selected} structure in your command line but you don't have a token selected when you run the command. Your sample command line (as provided) has NO @{selected} in it, only @{target}. That makes me think that there's something else to your process you're not sharing... Either command line verbiage you haven't included (which contains the reference to @{selected} ) or another script that is running when you send a message (for instance, a script that is responding to every chat message with a message that includes a reference to the selected token; that prompts the error, which is, itself, a new message the pending script responds to... giving you your loop). So when you talk about "clicking" on a token or "selecting a target", I don't know where in this process (I am having to fill in the gaps about) they are happening, or to what they are referring. I would suggest you post the full command line you're using (for each step you take), and we'll spot the references to a selected token. And/or we could find a way for the Metascript Toolbox to help do what you're trying to do. Finally, putting the @{target} syntax on a different line from the TokenMod command (outside the double braces) will not work. Your @{target} syntax resolves down to the id of the token, and it becomes that in command line in the position where it is supplying the ID to the TokenMod --ids argument. If it isn't there, that id isn't seen by that argument.