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.

November 28 (4 months ago)

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!


November 28 (4 months ago)
Andrew R.
Pro
Sheet Author

You’ll want to use the MetaScriptToolbox to get TokenMod to act on all the Troll tokens individually. 

November 29 (4 months ago)

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.

November 29 (4 months ago)
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.

November 29 (4 months ago)
Joe
Pro

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. ;-) 

November 29 (4 months ago)

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!

December 01 (4 months ago)

Edited December 01 (4 months ago)

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).

January 03 (2 months ago)
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.

January 04 (2 months ago)
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!
January 04 (2 months ago)
Joe
Pro

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. :-)

January 04 (2 months ago)
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!

January 09 (2 months ago)

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.

January 09 (2 months ago)
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. 

January 09 (2 months ago)

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.

January 11 (2 months ago)

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.  

January 11 (2 months ago)
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.
January 11 (2 months ago)
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}
January 11 (2 months ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

There could also be other commands within the larger GM macro with the same issue.

January 11 (2 months ago)

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.  

January 11 (2 months ago)


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



January 11 (2 months ago)
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.

January 12 (2 months ago)
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.

January 23 (2 months ago)

Where does token-mod call the information from that it displays in chat, when you select one of the condition-assigned status markers? i.e. whenever you select the sleepy status marker a description for Unconscious is displayed in chat.

Is that in a table that can be edited, or added to, or does in come from within the API, and therefore not editable?

January 23 (2 months ago)


Zim Astrofal said:

Where does token-mod call the information from that it displays in chat, when you select one of the condition-assigned status markers? i.e. whenever you select the sleepy status marker a description for Unconscious is displayed in chat.

Is that in a table that can be edited, or added to, or does in come from within the API, and therefore not editable?

Are you using the Condefinition script?  It sounds like that's the output you're describing.  If not, please post a screenshot. (Condefinition uses TokenMod as a dependency script.)

January 24 (2 months ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

To add to that, Condefinition has an editable array where all of the assignments, definitions and tests are stored.

I'd like to edit the script to make it more user-friendly with a GUI interface for setting the definition of the array, but... time. I do have a prototype that can work with the 2024 sheet, but it still only marks conditions by token markers. I'm hoping that the 2024 sheet will eventually expose the conditions attributes.

January 24 (2 months ago)

Here are screenshots of the API mod I currently have running and screenshots depicting what I had referred to in my previous post. I'd like to be able to edit the list of token markers used and be able to edit and add new conditions or other descriptions for spell marker for such things as hex or hunter's mark, etc., if that is possible.


January 24 (2 months ago)

Also, rather than selecting from the token buttons, I sometimes automate the token marker to trigger and set to the selected token, whenever I would use an action that triggers a condition, by adding this line to the action macros--for say something like Frighten action: 

!token-mod --ids @{target|Select a Token|token_id} --set statusmarkers|screaming

January 24 (2 months ago)
timmaugh
Pro
API Scripter

What is the command (or in-game action) that triggers that condition being rendered in chat, Zim?

January 24 (2 months ago)

I have a new question, kinda related, but not exactly. I have a macro for clearing all condition token markers from a selected token. My trouble with it is that it deletes/clears Bar 3 completely. Sometimes a condition, say something like Incapacitated, will set the token's speed (my Bar 3 assignment) to zero. However, when I run the "Clear Conditions" macro, my intent is to reset it back to the character's full speed, say 30 ft.. Instead it is just emptying the value altogether. How can I edit this to do what I intend it to do?

!token-mod {{

  --set statusmarkers#= bar3_reset# has_bright_light_vision#yes]

}}

January 24 (2 months ago)


timmaugh said:

What is the command (or in-game action) that triggers that condition being rendered in chat, Zim?


Where it comes from is my question. By simply applying some a select group of token markers, to a character or NPC token, the display in chat is automatic. However, there is no other command that I set, other than simple adding one of the qualified token markers. 

The default token markers that work like this are: bleeding-eye (Blinded), broken-heart (Charmed), edge-crack (Deafened), screaming (Frightened), grab (Grappled), interdiction (Incapacitated), black-flag (Inspiration), ninja-mask (Invisibility), pummeled (Paralyzed), frozen-orb (Petrified), chemical-bolt (Poisoned), back-pain (Prone), fishing-net (Restrained), fist (Stunned), and sleepy (Unconscious). The rest of the default token markers do nothing in this manner. Which is why I am looking to try making more that will display something in chat in the same template shown in my screenshot (above) from the other unused default token markers or other custom token marker. 

My assumption is that TokenMod makes all this happen since !token-mod --set statusmarkers| is what is used to add the token marker to the token. But, I am unclear if the descriptions live within the API or whether it is being pulled from a table I have yet to find.


January 24 (2 months ago)

timmaugh said:

What is the command (or in-game action) that triggers that condition being rendered in chat, Zim?

Based on the screenshot, it is the StatusInfo script


Zim Astrofal said:

Is that in a table that can be edited, or added to, or does in come from within the API, and therefore not editable?

To modify the list of conditions, you'll have to edit the StatusInfo code directly in the 'defaults' section starting on line 627.


Zim Astrofal said:

I have a new question, kinda related, but not exactly. I have a macro for clearing all condition token markers from a selected token. My trouble with it is that it deletes/clears Bar 3 completely. Sometimes a condition, say something like Incapacitated, will set the token's speed (my Bar 3 assignment) to zero. However, when I run the "Clear Conditions" macro, my intent is to reset it back to the character's full speed, say 30 ft.. Instead it is just emptying the value altogether. How can I edit this to do what I intend it to do?

!token-mod {{

  --set statusmarkers#= bar3_reset# has_bright_light_vision#yes]

}}

Just modify the portion that resets bar3:

!token-mod {{
--set statusmarkers#= bar3_value#30 has_bright_light_vision#yes] }}

bar3_reset only works to reset the 'current' value to the value in the 'max' field.  If you're using Bar 3 to only list a 'current' value and a blank 'max' value, then resetting it will make the 'current' value blank as well. Alternatively you could adjust the 'max' value to whatever the character's normal speed is supposed to be, but that will also mean that the bar will be displayed on the token - if there is a value in both the 'current' and 'max' fields for token bar, then the bar will be shown.

January 25 (2 months ago)

To modify the list of conditions, you'll have to edit the StatusInfo code directly in the 'defaults' section starting on line 627.

!token-mod {{

  --set statusmarkers#= bar3_reset# has_bright_light_vision#yes]

}}


Just modify the portion that resets bar3:

!token-mod {{
--set statusmarkers#= bar3_value#30 has_bright_light_vision#yes] }}

bar3_reset only works to reset the 'current' value to the value in the 'max' field.  If you're using Bar 3 to only list a 'current' value and a blank 'max' value, then resetting it will make the 'current' value blank as well. Alternatively you could adjust the 'max' value to whatever the character's normal speed is supposed to be, but that will also mean that the bar will be displayed on the token - if there is a value in both the 'current' and 'max' fields for token bar, then the bar will be shown.

I figured out that StatusInfo has a very easy way to add and edit the conditions built into it: !condition config See the image below and the READ ME at https://github.com/RobinKuiper/Roll20APIScripts/blob/master/StatusInfo/README.md

And I create a query to reset the tokens bar 3 value. Thank you for clarifying _reset vs. _value! Here is what I came up with:

/em @{selected|character_name} is relieved of all conditions

!token-mod {{ 

--set statusmarkers#= bar3_value|?{Set Speed to:|0}# has_bright_light_vision#yes]

}}


So, I'm good on everything now. Thank you for your help @Jarren.


January 25 (2 months ago)

Here is that image:

January 25 (2 months ago)

January 25 (2 months ago)

Any ideas on how to fix this?

"Error: No attribute or sheet field found for character_id -NDbWUOX-M7pxtSeiLeu named character_sheet"

It keeps popping up in the Mod Output Console, line-after-line, whenever I make status changes to any token. The only difference from one token to another is the character-id codes. Everything else is working fine inside the game. It is just that I am stumped as to why all the errors are being recorded every time I use it. Some Ive tested on are NPC character sheet and some are dndbeyond character sheets brought in with Beyond20--and for those there is a mirror Roll 20 character sheet, just not complete. 

Is there something I need to do on the character sheets?

February 04 (1 month ago)
The Aaron
Roll20 Production Team
API Scripter

Update v0.8.82 -- Support for disableSnapping and disableTokenMenu (Jumpgate).


isdrawing split properties: disableSnapping and disableTokenMenu (Jumpgate)

On Jumpgate, these two properties control the individual facets of what was handled by isdrawing. You can set disableSnapping to true to prevent a graphic from snapping to the page's grid lines while still retaining the bubbles and token menu:

!token-mod --set disableSnapping|yes

Setting disableTokenmenu to true will hide the token menu while still snapping the graphic to the grid:

!token-mod --set disableTokenMenu|yes

Setting isdrawing on Jumpgate will set both disableSnapping and disableTokenMenu. These two commands have the same effect:

!token-mod --set isdrawing|yes
!token-mod --set disableSnapping|yes disableTokenMenu|yes

If not on Jumpgate, setting either disableSnapping or disableTokenMenu will be the same as setting isdrawing. These will all be the same if not on Jumpgate:

!token-mod --set isdrawing|yes
!token-mod --set disableTokenMenu|yes
!token-mod --set disableSnapping|yes

If setting both, be sure to set the one that is more important to you second as it will set isdrawing. In this example, if not on Jumpgate, you'll end up with snapping and token menus:

!token-mod --set disableSnapping|no disableTokenMenu|yes
February 04 (1 month ago)
Joe
Pro

Nice flexibility enhancement, thank you!

March 12 (2 weeks ago)

I'm trying to make a drop down template macro for my players to be able to choose which token marker they want to add, but I'm having difficulties because the pipe breaks lines in the drop down template. So whenever I try to do this, as an example:

&{template:desc} {{desc= ?{Add Token Marker|
Bleeding, **Added Bleeding** !token-mod --set statusmarkers|Bleeding::243216}}}

It breaks off the first "option" at statusmarkers to create a new line for everything after, thus not actually doing what I need it to do.

Is there a way around this or can I not use these in a drop down template?

March 12 (2 weeks ago)


Tritch said:

I'm trying to make a drop down template macro for my players to be able to choose which token marker they want to add, but I'm having difficulties because the pipe breaks lines in the drop down template. So whenever I try to do this, as an example:

&{template:desc} {{desc= ?{Add Token Marker|
Bleeding, **Added Bleeding** !token-mod --set statusmarkers|Bleeding::243216}}}

It breaks off the first "option" at statusmarkers to create a new line for everything after, thus not actually doing what I need it to do.

Is there a way around this or can I not use these in a drop down template?

TokenMod explicitly uses the hashtag/pound symbol as an alternative for just this reason:

&{template:desc} {{desc= ?{Add Token Marker|
Bleeding, **Added Bleeding** !token-mod --set statusmarkers#Bleeding::243216}}}

However, your query output won't work, because the TokenMod command comes after your '**Added Bleeding**' chat message. You'll need to add an html entity line break before the TokenMod command for it to run (aircoded so hopefully I didn't forget something):

&{template:desc} {{desc= ?{Add Token Marker|
Bleeding, **Added Bleeding** 
!token-mod --set statusmarkers#Bleeding::243216}}}
March 12 (2 weeks ago)

Edited March 12 (2 weeks ago)

EDIT: nvm, I figured it out.

You have to put the !token-mod part before the drop down stuff.

!token-mod &{template:desc} {{desc= ?{Add Token Marker|
Bleeding, --set statusmarkers#Bleeding::243216 |
Blinded, --set statusmarkers#Blinded::6117931}}}

Thanks for your help with the #, idk how I missed that from the handout.


That's very helpful and moving me in the right direction but I still can't seem to get the drop down to work correctly. 

Here's what happens when I copy/paste yours exactly.


I'm sure this issue has moved beyond the API script and should probably be asked elsewhere now, I apologize.

And just to be clear, nothing was added to the token either.

11:19AM (13 hours ago)

Edited 11:20AM (13 hours ago)

I'm trying to create a simple map swapper, I'm using the newish feature of DMs being able to have items on the page but off the viewable map area.

I have a combo of token-mod and the fetch APIs to let me select the current map and then click from a selection of alt maps that are available and swap them, it's switching the one from off the map to the map and setting it to the right size but it's not doing anything with the current map, can you tell me where i'm going wrong? Here's my code (it's all in one macro):

!token-mod --ids @{target|token_id} --ignore-selected --set top|@(@{selected|token_id}.top) left|@(@{selected|token_id}.left) width|@(@{selected|token_id}.width) height|@(@{selected|token_id}.height)
!token-mod --ids @{selected|token_id} --ignore-selected --set top|@(@{target|token_id}.top) left|@(@{target|token_id}.left) width|@(@{target|token_id}.width) height|@(@{target|token_id}.height)
thanks

2:27PM (9 hours ago)
The Aaron
Roll20 Production Team
API Scripter

Try taking the ! off the front and see if you're getting different IDs being passed for the selected and target. There was a bug with the 2024 character sheet where target and selected could get overwritten, it might be back?