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.

That would be a question for the Roll20 Devs
1639801761
The Aaron
Roll20 Production Team
API Scripter
And one I ask monthly...
1639810482
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Mike W. said: Thanks Keith Do you have any idea when this will be addressed? None at all, unfortunately. These things get fixed when the Powers That Be get to them. :( It's been mentioned many times.
1639959730

Edited 1639959743
Is it possible to trigger a script from an Ability that was invoked via a querry? Here is the main macro: ?{Posture|Stand,%{GUNS|Stand}|Prone,%{GUNS|Prone}|Fall,%{GUNS|Fall}|Crouch,%{GUNS|Crouch}|Sit/Kneel,%{GUNS|Sit}} And here is one of the Abilities: **@{selected|token_name}** drops prone. !token-mod --set statusmarkers|fall The first line works fine, but the second fails to trigger.
1639961469
The Aaron
Roll20 Production Team
API Scripter
Hmm. I'd think that would work, try adding the is explicitly: !token-mod --set statusmarkers|fall --ids @{selected|token_id}
Nope. I get " fall --ids -MlRsESsiIPVXhg1XnLm " showing up in the dropdown
1639963771

Edited 1639964061
**@{selected|token_name}** drops prone. !token-mod --set statusmarkers|blue Sustituting the | keeps the querry from breaking, but tther script call still gets swallowed without reaction. Never mind, restarted the sandbox and it works now.
Apologies if I've missed it from earlier or elsewhere, but I am looking for TokenMod macro script to easily change a token's Updated Dynamic Lighting setting, just like how I did it below with Legacy Lighting. Appreciate if you can point me in right direction for help with this. Thanks! !token-mod --set ?{Vision|Torch, light_radius#40 light_dimradius#20 light_hassight#yes light_angle#360 light_otherplayers#yes|Light Spell, light_radius#40 light_dimradius#20 light_hassight#yes light_angle#360 light_otherplayers#yes|Goggles of Night, light_radius#60 light_dimradius#=-5 light_hassight#yes light_angle#360 light_otherplayers#no|No Light Source, light_radius#5 light_dimradius#=-5 light_hassight#yes light_angle#360 light_otherplayers#no|Hooded Lantern, light_radius#60 light_dimradius#30 light_hassight#yes light_angle#360 light_otherplayers#yes|Hooded Lantern (Hood Down), light_radius#60 light_dimradius#5 light_hassight#yes light_angle#360 light_otherplayers#yes|Bullseye Lantern, light_radius#120 light_dimradius#60 light_angle#60 light_hassight#yes light_otherplayers#yes|Lamp, light_radius#30 light_dimradius#15 light_hassight#yes light_angle#360 light_otherplayers#yes|Candle, light_radius#5 light_dimradius#=0 light_hassight#yes light_angle#360 light_otherplayers#yes|Darkvision, light_radius#60 light_dimradius#=-5 light_hassight#yes light_angle#360 light_otherplayers#no|Darkvision (90'), light_radius#90 light_dimradius#=-5 light_hassight#yes light_angle#360 light_otherplayers#no|Darkvision (120'), light_radius#120 light_dimradius#=-5 light_hassight#yes light_angle#360 light_otherplayers#no|Darkvision (300'), light_radius#300 light_dimradius#=-5 light_hassight#yes light_angle#360 light_otherplayers#no|Warlock Devil's Sight, light_radius#120 light_dimradius#=120 light_hassight#yes light_angle#360 light_otherplayers#no|No Light Source (Dusk), light_radius#120 light_dimradius#=-5 light_hassight#yes light_angle#360 light_otherplayers#no|Fog, light_radius#200 light_dimradius#=5 light_hassight#yes light_angle#360 light_otherplayers#no|Blinded, light_hassight#no light_angle#360 light_otherplayers#no|Blindsight, light_radius#60 light_dimradius#=-5 light_hassight#yes light_angle#360 light_otherplayers#no}
KofaSing KoodGarma said: Apologies if I've missed it from earlier or elsewhere, but I am looking for TokenMod macro script to easily change a token's Updated Dynamic Lighting setting, just like how I did it below with Legacy Lighting. Appreciate if you can point me in right direction for help with this. Thanks! This is how I have my UDL setup.  I make macros for each case, Torch, Bull, Dark Vision, ... It then make a macro that is a menu that calls the one I need. This way I can use just the macro or the menu. I have a menu for players that lets them light a torch or put it out, and another for me that includes Dark Vision settings.  UDL-Bull !token-mod --on emits_bright_light has_directional_bright_light --off emits_low_light --set bright_light_distance#120 low_light_distance#60 directional_bright_light_center#90 directional_bright_light_total#10 UDL-Darkvison-120 !token-mod --on has_night_vision --set night_vision_distance#120 UDL-Darkvison-60 !token-mod --on has_night_vision !token-mod --set night_vision_distance#60 UDL-Darkvison-Off !token-mod --off has_night_vision --set night_vision_distance#0 UDL-Hooded-Lantern-Closed !token-mod --on emits_low_light --off emits_bright_light has_directional_bright_light --set low_light_distance#5 bright_light_distance#0 UDL-Hooded-Lantern-Open !token-mod --on emits_bright_light emits_low_light --off has_directional_bright_light --set bright_light_distance#30 low_light_distance#30  UDL-Light-15-15 !token-mod --on emits_bright_light emits_low_light --off has_directional_bright_light has_directional_dim_light --set bright_light_distance#15 low_light_distance#15 directional_bright_light_center#0 directional_bright_light_total#0  I use this or an edited version of this when setting up a map where I want multiple light sources set the same. Add a small token, like a dot, to a map and run this macro.  UDL-Light-Dynamic !token-mod --on emits_bright_light emits_low_light --off has_directional_bright_light has_directional_dim_light --set bright_light_distance#?{Bright} low_light_distance#?{Dim} directional_bright_light_center#0 directional_bright_light_total#0 Dynamically adjust lighting on the fly. This pops up a window asking for the bright and dim distance. Select a token and run the macro to change the light on the fly, fast and easy. Want the camp fire light to reduce as the night goes on to simulate the fire dying out, this is your macro.  UDL-Snuff !token-mod --off emits_bright_light emits_low_light --set directional_bright_light_center#0 directional_bright_light_total#0 UDL-Torch !token-mod --on emits_bright_light emits_low_light --off has_directional_bright_light has_directional_dim_light --set bright_light_distance#20 low_light_distance#20 directional_bright_light_center#0 directional_bright_light_total#0  UDL-Light-Menu ?{Light|Snuff,#UDL-Snuff |Torch,#UDL-Torch |Bullseye,#UDL-Bull |Hooded Lantern Open,#UDL-Hooded-Lantern-Open |Hooded Lantern Closed,#UDL-Hooded-Lantern-Closed } I give players access to this menu. They can then turn on and off their torches or lanterns. It doe not include the darkvision choices.  UDL-Light-Menu-DM ?{Light|Snuff,#UDL-Snuff |Torch,#UDL-Torch |Bullseye,#UDL-Bull |Hooded Lantern Open,#UDL-Hooded-Lantern-Open |Hooded Lantern Closed,#UDL-Hooded-Lantern-Closed |Dark-60,#UDL-Darkvison-60 |Dark-120,#UDL-Darkvison-120 |No Darkvison,#UDL-Darkvison-Off } I use this menu, it includes the darkvision choices. 
I am trying to invoke this abbilty via a querry selection. Which parts do I need to replace with html? !token-mod --set {&if @{selected|bar1} <= [[(@{selected|Fatigue|max}/4)+1]].value } statusmarkers|green {&end} Presumably the last | with | but what about the others inside? And which of the } should I replace ( } ). Anything else Im missing?
1640812653
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Where does the syntax for {&if} and {&end} come from? That's not tokenmod. Does it come from one of Timmaugh's meta scripts?
keithcurtis said: Where does the syntax for {&if} and {&end} come from? That's not tokenmod. Does it come from one of Timmaugh's meta scripts? Yes, one of those.
APILogic Kaspar K. said: keithcurtis said: Where does the syntax for {&if} and {&end} come from? That's not tokenmod. Does it come from one of Timmaugh's meta scripts? Yes, one of those.
It sounds like you want to include this block in a roll query. I think you could something like: ?{Query Prompt|!token-mod --set {&if @{selected|bar1} <= [[(@{selected|Fatigue|max}/4)+1]].value } statusmarkers | green {&end } } The other }s and | should get parsed by the chat server as part of evaluating the @{blah|blah} constructions before the roll queries. You may need to add in a ZeroFrame deferral (I'm not sure...): ?{Query Prompt|!token-mod --set { \ &if @{selected|bar1} <= [[(@{selected|Fatigue|max}/4)+1]].value } statusmarkers|green { \ &end}} Although I'm wondering what the point of using the APILogic inside  the token-mod call is for. I don't know exactly  what you're trying to do, but it seems like this is a more straightforward construction: ! {&if @{selected|bar1} <= [[(@{selected|Fatigue|max}/4)+1]].value }token-mod --set statusmarkers|green {&end} Your token-mod call only does one thing--set a status marker--and is only dependent on a single if . If the if yields false, you're left with a call to token-mod that doesn't do anything. Kaspar K. said: I am trying to invoke this abbilty via a querry selection. Which parts do I need to replace with html? !token-mod --set {&if @{selected|bar1} <= [[(@{selected|Fatigue|max}/4)+1]].value } statusmarkers|green {&end} Presumably the last | with | but what about the others inside? And which of the } should I replace ( } ). Anything else Im missing?
The Aaron said: The Aaron said: Sasha said: I noticed that the remove status marker command for multiple instances of the same marker has been changed to only remove the rightmost instance instead of every instance of that marker. Now, the command   "!token-mod --set statusmarkers|-blue[]"    removes only one instance of the blue status, but what if I do want to remove all of them? It's pretty awkward to count the instances and remove them one by one, and I don't want to clear all status markers of every type, just certain ones. Is there still a convenient way to clear all status markers of a particular name? Sorry for the late reply, no idea how I missed this. You should be able to remove all of them by leaving the brackets off: !token-mod --set statusmarkers|-blue Huh... this seems to have broken.  I'll look at fixing it. Thanks! I tried removing the brackets and it still did the same thing, as I guess you've seen. I didn't realize it was a bug.
1640895334
timmaugh
Pro
API Scripter
Colin C. said: It sounds like you want to include this block in a roll query. I think you could something like: ?{Query Prompt|!token-mod --set {&if @{selected|bar1} <= [[(@{selected|Fatigue|max}/4)+1]].value } statusmarkers | green {&end } } The other }s and | should get parsed by the chat server as part of evaluating the @{blah|blah} constructions before the roll queries. You may need to add in a ZeroFrame deferral (I'm not sure...): ?{Query Prompt|!token-mod --set { \ &if @{selected|bar1} <= [[(@{selected|Fatigue|max}/4)+1]].value } statusmarkers|green { \ &end}} Although I'm wondering what the point of using the APILogic inside  the token-mod call is for. I don't know exactly  what you're trying to do, but it seems like this is a more straightforward construction: ! {&if @{selected|bar1} <= [[(@{selected|Fatigue|max}/4)+1]].value }token-mod --set statusmarkers|green {&end} Your token-mod call only does one thing--set a status marker--and is only dependent on a single if . If the if yields false, you're left with a call to token-mod that doesn't do anything. Kaspar K. said: I am trying to invoke this abbilty via a querry selection. Which parts do I need to replace with html? !token-mod --set {&if @{selected|bar1} <= [[(@{selected|Fatigue|max}/4)+1]].value } statusmarkers|green {&end} Presumably the last | with | but what about the others inside? And which of the } should I replace ( } ). Anything else Im missing? Colin's right on the money. To answer the confusion about a ZeroFrame deferral, this case should not need it. The roll equation is straightforward, and everything is available by the time Roll20 would want to parse the inline roll. As long as the contents of the Fatigue attribute is either a value or a valid roll equation, this will work. That said, the *other* thing that could make it require a deferral would be if we were using this query + TokenMod construction in a forselected operation (to apply to many different tokens)... but I doubt that's what we have going on in this case. If so, I just posted an example of that. It would not change what query substitutions Colin highlighted, above.
So, I am using Token Mod, ChatSetAtr and APILogic. **@{selected|token_name}** takes Aim at **@{target|token_name}** !{&eval(^)}!setattr --sel --silent --Cond| Aiming At @{target|token_name}{^&select @{selected|token_id}}{&/eval} !{&eval(^)}!token-mod --set tooltip|"Aiming At @{target|token_name}@{selected|Pose}"{^&select @{selected|token_id}}{&/eval} Problem is, the second eval is ignored. Any way to combine the two together?
I noticed an issue earlier with tool tips and HP tracking. I wanted to be able to use the tool tip to track HP dynamically since it reads out more clearly than the health bars. Unfortunately it doesn't change when the HP total changes. ie. A character has a maximum HP pool of 30. I use the following command to populate the tooltip:  !token-mod --set tooltip|"HP: @{selected|bar2}" --on show_tooltip When I subtract HP from the value (let's say the PC gets hit for 20 HP), the tooltip still says "30" which was the value when I activated the command. I haven't found a way to clear this save for manually deleting the contents and running the macro above again. Any ideas?
1641112481
Andrew R.
Pro
Sheet Author
The tooltip doesn't work that way, but a script to make that happen was posted a while ago.  I've found the tooltip excellent for stuff that doesn't change too much, and use it for 13th Age AC, PD, & MD in monster tokens. I don't need secrecy for that, and it has sped up my game pleasantly. 
1641141659
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The tooltip is just plain text. It doesn't interpret attribute calls, support roll buttons, graphics or anything like that.
1641143547
timmaugh
Pro
API Scripter
Kaspar K. said: So, I am using Token Mod, ChatSetAtr and APILogic. **@{selected|token_name}** takes Aim at **@{target|token_name}** !{&eval(^)}!setattr --sel --silent --Cond| Aiming At @{target|token_name}{^&select @{selected|token_id}}{&/eval} !{&eval(^)}!token-mod --set tooltip|"Aiming At @{target|token_name}@{selected|Pose}"{^&select @{selected|token_id}}{&/eval} Problem is, the second eval is ignored. Any way to combine the two together? Yes, you can combine them if they're both EVALs (by using the deferral character of the first one to "hide" the detection of the second one until the first is running), but it's easier just to promote one to be a full statement and let the other EVAL embed itself in that base call. In other words, promote CSA to be a call to itself (no EVAL), then put the EVAL-TokenMod statement in it. That would look like this: **@{selected|token_name}** takes Aim at **@{target|token_name}** !setattr --sel --silent --Cond| Aiming At @{target|token_name}{&select @{selected|token_id}}{&eval(^)}token-mod --set tooltip|"Aiming At @{target|token_name} @{selected|Pose}"{^&select @{selected|token_id}}{&/eval} One thing about this, though... because of the way TokenMod parses the line, you might run into a problem if there is no "Pose" attribute for the selected token character. In that case, you get the message in chat that Roll20 couldn't find the attribute, and the "selected|Pose" text is left in the line. Then TokenMod parses on the pipe character, and the command is borked. If you aren't sure the token will have a Pose attribute (maybe it does in the system you're playing - there wasn't one in my test game), then you could use Fetch and include a default value: @(selected.Pose[Pointer Dog]) That way there is no pipe character at all, and if the attribute isn't found you still have some text to go into the tooltip.
I've looked everywhere for the answer and it's probably very straight forward, but I'm using TokenMod and I can't get the name plates removed from the tokens. Both GM and Players see all the token names as they are listed in the details section. Is there a way to remove them from the player's view or from both? I've tried several of the !token-mod commands with no luck, any help is greatly appreciated. Thanks all!     
1641457955
Andrew R.
Pro
Sheet Author
I think you want  --off showplayers_name 
So this macro was working for my last session (~ early December) and now doesn't seem to anymore? The API Output Console simply says "Handle Status Marker Change" but nothing actually happens to my token.  !token-mod{{   --set     bar3|[[@{selected|npc_hpformula}]]     bar2_current|[[@{selected|npc_speed}]]     bar1_current|[[@{selected|npc_ac}]]     showplayers_bar3|yes    --off has_bright_light_vision    --off emits_bright_light    --on showplayers_name }} 
1641501572
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Try putting a space after !token-mod.
keithcurtis said: Try putting a space after !token-mod. If I didn't know that this is the first time I've actually opened up that macro in something like 2 years I'd be smacking myself in the head ;) That worked, thanks!!
Andrew R. said: I think you want  --off showplayers_name  Thank you for the help, I tried this and still it wont let me remove the names on the GM or Player view and they didn't remove themselves. NOt sure if there's still something i'm missing.
Trubo732 said: Andrew R. said: I think you want  --off showplayers_name  Thank you for the help, I tried this and still it wont let me remove the names on the GM or Player view and they didn't remove themselves. NOt sure if there's still something i'm missing. I just figured it out, the health AuraTint API was controlling the view of the names and conflicting with token mod. Thanks for the help!
1641934853

Edited 1641947476
Can Tokenmod move drawings to other layers? I've got a drawn line selected on the Objects layer that I want to move to dynamic lighting and when I run  !token-mod --set layer|walls nothing happens. Are they not really tokens even though @{selected|token_id} gives me a token id.  Thanks! Edit: Ah-ha! Never mind, I integrated the Door Knocker script into the macro and problem solved!
I have a Dragon that can assume Human form. I currently have a multiside token for this creature. What I am looking to do is when the token switches to dragon form I want it to change size to like 1050X1050 pixels. How would I go about writing a tokenmod action for this? I found an old post that included this script langage but it doesn't seem to work for me. Any thoughts? (And yes I changed the names in this script to the names of the tokens in my game) !token-mod {{ --set ?{Side|Regular,currentside#1 size#70|Air Elemental,currentside#2 size#140} }}
1642177005
The Aaron
Roll20 Production Team
API Scripter
Use scale instead of size: !token-mod {{ --set ?{Side|Regular,currentside#1 scale#1u|Air Elemental,currentside#2 scale#2u} }} Some notes: # is equivalent to | (pipe), but is useful so you don't break things like Roll Queries. scale#num is shorthand for width#num height#num The numbers for distances/sizes can have a unit attached. Some examples are u is 70px, g is the size of a grid square, ft (m, in, etc) is whatever scale your have set to the map, px is pixels.  Regular and Air Elemental are just labels humans will see, so won't affect the API. 
Works perfectly Aaron! thanks!
Hello, I'm building a Conditions macro to set/remove status markers with TokenMod within a chat query, like this: /w gm &{template:desc} {{desc=**SET STATUS CONDITIONS** for: @{selected|token_name} ... more here ... [Blinded](!token-mod --set statusmarkers#!Blinded;;243174) | ... more here ... }} I can use '+' and '-' to add and remove conditions but '!' only sets it does not toggle them. I suspect that the problem is that the outer query is eating the '!'. I looked at the script code and unlike with '|' and ':' there's no substitute character for '!'. If there's no workaround you can suggest please add a substitute operator character such as '~', thank you.
1643569130
The Aaron
Roll20 Production Team
API Scripter
Hmm.  I tried copying your macro and running it (with a status marker I have) and it didn't have any issue doing the substitution.  Try running it, then push up in the chat and see what command was sent.  See if that command works for you, and what modifications you need to do to get it working if it doesn't.  The ! character won't get eaten by commands wrapping it, so it shouldn't need a substitution.  If you want to try a substitution, use ! for the ! in the full macro.
Sami T. said: Hello, I'm building a Conditions macro to set/remove status markers with TokenMod within a chat query, like this: /w gm &{template:desc} {{desc=**SET STATUS CONDITIONS** for: @{selected|token_name} ... more here ... [Blinded](!token-mod --set statusmarkers#!Blinded;;243174) | ... more here ... }} I can use '+' and '-' to add and remove conditions but '!' only sets it does not toggle them. I suspect that the problem is that the outer query is eating the '!'. I looked at the script code and unlike with '|' and ':' there's no substitute character for '!'. If there's no workaround you can suggest please add a substitute operator character such as '~', thank you. Don't you normally have to use :: in front of your custom marker istead of ;; ?
1643570758
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It's a token-mod-available substitute, to allow calls to be made inside of dropdown queries without breaking them.
1643574093
The Aaron
Roll20 Production Team
API Scripter
keithcurtis said: It's a token-mod-available substitute, to allow calls to be made inside of dropdown queries without breaking them. The : as ; is technically to fix API Command Buttons, but the idea is the same. 
Hmm.  I tried copying your macro and running it (with a status marker I have) and it didn't have any issue doing the substitution.  Try running it, then push up in the chat and see what command was sent.  See if that command works for you, and what modifications you need to do to get it working if it doesn't.  The ! character won't get eaten by commands wrapping it, so it shouldn't need a substitution.  If you want to try a substitution, use ! for the ! in the full macro. I tried it again and this time it worked?! Well, that's odd. Perhaps relaunching the game had something to do with this? Anyway, it's all good now, thanks!
1643649865

Edited 1643650063
One question : Is it possible when a character switches side on his token (druid switching to wolf for example) that the "speak as" chat relates to this new side ? EDIT : via token mod of course :)
1643650498
The Aaron
Roll20 Production Team
API Scripter
The API can certainly set the Speaking As.  There may be some API scripts that do that already.  The problem would be how to maintain the mapping from the image at a position to the character to speak as.  If you were running two API commands in tandem, like: !token-mod --set currentside|3 !set-speaking-as Wolf That would certainly be doable.
!set-speaking-as ??? what is that secret API call ??? is that part of token-mod ? i just looked quickly through forums but couldn't find this referenced script ! Thank you for answering though ;)
I think that was a hypothetical script name example. I have one called “Switch”, but I don’t have a link off hand, unfortunately. Might have been a custom one-off from Aaron. ;-) My notes are: •  Switch: Change speaking as using “!switch @{selected|character_id}” or just “!switch” to go back to speaking as player
Found it:&nbsp; <a href="https://app.roll20.net/forum/post/7565888/script-snippet-switch-swap-your-speaking-as-and-avatar-easily" rel="nofollow">https://app.roll20.net/forum/post/7565888/script-snippet-switch-swap-your-speaking-as-and-avatar-easily</a>
1643656748
The Aaron
Roll20 Production Team
API Scripter
Oh!&nbsp; Forgot I wrote that. =D
Is that like the “he's forgotten more than we'll ever know” kind of the thing? :D
1643683534
The Aaron
Roll20 Production Team
API Scripter
I can't remember. =D
The Aaron said: The API can certainly set the Speaking As.&nbsp; There may be some API scripts that do that already.&nbsp; The problem would be how to maintain the mapping from the image at a position to the character to speak as.&nbsp; If you were running two API commands in tandem, like: !token-mod --set currentside|3 !set-speaking-as Wolf That would certainly be doable. Hi Aaron, How can I set this up as a drop down menu that allows me to choose a specific size?
1643847557
The Aaron
Roll20 Production Team
API Scripter
I'd suggest building a chat menu with api command buttons for each face and speaking as option.&nbsp;
1643916366

Edited 1643917788
I like the new Tooltip option and I was trying to create a macro that sets the Tooltip to the npc_name. But I think I'm using the wrong variable. The command I'm using is: --set tooltip|@{selected|name} but that is setting Tooltip to the first word in Represents Character (in the example below it sets it to Tavern) but what I really want its for it to use Name (as in Conrad). Can someone tell me what to change? (and also how to get it to not just use up to the first blank?)