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.

December 30 (4 years ago)

Edited December 30 (4 years ago)
Styx
Pro

Question - Is it possible to use Token-Mod to group selected (or preset) tokens?

Example - I'm about to start a ROTF campaign and one of my players had already bought a dogsled and 2 dogs in session zero. I'd like to see if I can set a Token Action macro to toggle grouping of the 3 separate tokens I have for the 2x dogs and 1x sled (potentially adding the PC token at some point too).

I've seen the Carry Token script, but found it too easy to deselect the group when moving the grouped tokens, thus breaking the "carry" function.

EDIT: Thinking about this, I can't see how there could be a way that is different to the click+drag select process or even if there was a way that it would be temporary. Hmm..


Side note, I edited the "Vision" macro I posted above to apply only to Prop Tokens while also setting their Name to the changed Light Source. Only sharing this because I love the QoL change this has brought me as a new DM who does data analytics for a living and gets too easily caught up in automation efficiencies ;)

Thank you again

December 30 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Grouping isn't exposed to the API.

@Styx, you could accomplish this with the Marching Order script. It lets you save token formations so they'll follow the leader in roughly the same formation, and you can even have multiple formations active simultaneously.

December 31 (4 years ago)
Styx
Pro


Persephone said:

@Styx, you could accomplish this with the Marching Order script. It lets you save token formations so they'll follow the leader in roughly the same formation, and you can even have multiple formations active simultaneously.


Cool, thanks, I'll look into that!

I had a feeling @The Aaron

January 01 (4 years ago)

Hey Aaron, just wanted to say thanks for all you've done for all of us fellow nerds! I apologize if this has already been addressed, but I've been trying to make a macro with tokenmod that both lights a torch and snuffs a torch with one macro as to not crowd the macro bar. What I currently have sets bright light for 20 feet and also snuffs the torch if the token is already emitting light, but still does not add the 20 feet of dim light that comes with lighting a torch. Maybe you can help! I'm new to scripts and macros in general, but trying to learn! Here's what I have so far:

!token-mod {{
  --on
    has_bright_light_vision
    emits_bright_light
    emits_low_light
  --set
    bright_light_distance|!20
    low_light_distance|!20
}}
January 01 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

You could try this:

!token-mod {{
  --flip
    has_bright_light_vision
    emits_bright_light
    emits_low_light
  --set
    bright_light_distance|!20
    low_light_distance|!20
}}

I tend to prefer using a Roll Query to be prompted for the type of light:

!token-mod ?{Light|None,--off has_bright_light_vision emits_bright_light emits_low_light --set bright_light_distance#0 low_light_distance#0|Torch,--on has_bright_light_vision emits_bright_light emits_low_light --set bright_light_distance#20 low_light_distance#20}
I just typed that up to demonstrate, but you can add many, many different light options with that method.  Note that you replace the pipe for TokenMod arguments with a # so you don't have to escape it.
January 01 (4 years ago)
Ahh thank you so much Aaron! You're the man 
January 01 (4 years ago)

I had been playing around with night_vision_tint, but then I've of course been stung eventually by the subtractive light issue obscuring the map. I use token-mod to ensure consistent token settings, but can't see how to set it to transparent. To head off any "it defaults to it" comments, I need to confirm that players haven't set it differently in their vault to avoid the Roll20 bug. Thanks for your help with this one! (and happy new year to all)

January 01 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

You can just use the word "transparent":

token-mod --set night_vision_tint|transparent
January 03 (4 years ago)

Looking to run a macro for setting token image as below

!token-mod --set imgsrc|https://s3.amazonaws.com/files.d20.io/images/189907702/FE-msNwgc5faHtxLThCYqQ/max.png?1609711437} --ids @{selected|token_id} --set showname|no

but then have a second macro to revert to default character token image. 

!token-mod --set imgsrc|@{selected|character_id}  --set showname|yes

What is the call for a selected tokens default token image?

Thanks in advance.

January 03 (4 years ago)

This is with a token linked to a character of course.  Like it to be setup generic so its just a matter of choosing token to revert to default character token image.

January 04 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Hmm. I don't believe character IDs are supported for setting the image source, but I'll look into adding it. 

January 04 (4 years ago)

Great thanks.  

January 10 (4 years ago)

I'm having an issue where I try to blind someone using a macro, but it ONLY blocks bright light. It does not block dim light. Makes for an odd effect for sure. Is there a way to do this or can I just change the field of vision to 0 degrees? I didn't see a command posted a while ago of how to change the field of vision in chat/macro.

January 11 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Can you post the command you're using?  UDL is still a developing technology, sorry.

January 12 (4 years ago)

Edited January 13 (4 years ago)


The Aaron said:

Can you post the command you're using?  UDL is still a developing technology, sorry.


No reason to be sorry! I appreciate all the work! I've started learning how to do all this just to make the D&D experience more streamlined and immersion focused.

I used a lot of different variations of this to try to figure it out, but here is one:

 !token-mod {{

?{Light|Torch,

--on

    emits_bright_light

    emits_low_light

--set

    bright_light_distance#20

    low_light_distance#20|

Muted Torch,

--on

    emits_bright_light

    emits_low_light

--set

    bright_light_distance#10

    low_light_distance#10|

Candle,

--on

    emits_bright_light

    emits_low_light

--set

    bright_light_distance#5

    low_light_distance#5|

Extinguish,

--off

    emits_bright_light

    emits_low_light|

Blind,

--off

   has_bright_light_vision

   has_night_vision}

}}


-----I've also used, in conjunction with blind, light_hassight and has_low_light_vision but to no avail.

I wasn't sure of the list of commands other than the ones you posted in page 16 of this thread:

showname

showplayers_name

showplayers_bar1

showplayers_bar2

showplayers_bar3

showplayers_aura1

showplayers_aura2

playersedit_name

playersedit_bar1

playersedit_bar2

playersedit_bar3

playersedit_aura1

playersedit_aura2

light_otherplayers

light_hassight

isdrawing

flipv

fliph

aura1_square

aura2_square

has_bright_light_vision

bright_vision

has_night_vision

night_vision

emits_bright_light

emits_bright

emits_low_light

emits_low




January 19 (4 years ago)

Using TokenMod to set the value for the Updated Dynamic Lighting. I am having trouble getting the directional lighting to work correctly for a Bullseye Lantern it is 60 foot bright and 60 foot dim. If I manually change the Token Properties it work, but it does not work with TokenMod. There are three settings listed for directional dim light, are this included in Token Mod?

https://roll20.zendesk.com/hc/en-us/articles/360046490373-API-Support#directional-vision-and-lighting-0-2

  • has_directional_dim_light
  • directional_dim_light_center
  • directional_dim_light_total


Bob


January 19 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

The _dim_ versions on that link are a lie.  They only exist for bright light.  Here's the command that should set those:

!token-mod {{
  --on
    has_directional_bright_light
    emits_low_light
    emits_bright_light
    has_bright_light_vision
  --set
    directional_bright_light_center|90
    directional_bright_light_total|60
    low_light_distance|25
  }}

But it breaks UDL.  You can use that, and then just open and save the token and it will fix it.  They tried to roll out a fix to that before Christmas, but it broke things and they rolled it back.  Hopefully they'll get a fix for it sometime soon.

January 20 (4 years ago)

Hi The Aaron, first can I say I love your mods :D

Second is there a way to append certain text after a tokens name using tokenmod?
For example I am using tokennamenumber, and I would like to be able to add %%NUMBERED%% after the name so that the api will add incremental numbers after the name when multiple tokens are added to the map.


January 20 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Yup!

!token-mod --set name|"@{selected|token_name} %%NUMBERED%%"

You could use character_name instead if you'd rather  



The Aaron said:

Yup!

!token-mod --set name|"@{selected|token_name} %%NUMBERED%%"

You could use character_name instead if you'd rather  



Yeah, I have something like this as part of my monster setup macro. Set default token, change token name to Creature %%NUMBERED%%, set bar2 to npc_ac, set aura 2 to dark red (for emoting purposes).



January 20 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter


The Aaron said:

The _dim_ versions on that link are a lie.  They only exist for bright light.  Here's the command that should set those:

!token-mod {{
  --on
    has_directional_bright_light
    emits_low_light
    emits_bright_light
    has_bright_light_vision
  --set
    directional_bright_light_center|90
    directional_bright_light_total|60
    low_light_distance|25
  }}

But it breaks UDL.  You can use that, and then just open and save the token and it will fix it.  They tried to roll out a fix to that before Christmas, but it broke things and they rolled it back.  Hopefully they'll get a fix for it sometime soon.


As it turns out, there are properties, but they are _low_ instead of _dim_.  They're still broken in the same way, but you'll be able to set them when I next push out TokenMod.  This will be the command:

!token-mod {{
  --on
    has_directional_bright_light
    has_directional_low_light
    emits_low_light
    emits_bright_light
    has_bright_light_vision
  --set
    directional_bright_light_center|90
    directional_bright_light_total|60
    directional_low_light_center|90
    directional_low_light_total|60
    low_light_distance|25
  }}

January 21 (4 years ago)

Ok so my next thing is about setting dark vision distance - I can't get it to seem to work.
This is my mess of a macro at the moment (I can probably clean it up)

!token-mod {{
  --on showname showplayers_name  
  --off showplayers_bar2 showplayers_bar1  showplayers_bar3
  --on showplayers_aura1 showplayers_aura2
  --set bar1_link|fortune bar2_link|toughness_bonus bar3_link|Wounds
?{Nightvision|No, --on has_bright_light_vision --off has_night_vision --set_night_vision_distance#0|Yes, --on has_night_vision --set_night_vision_distance#20 }
?{Light|None,--on has_bright_light_vision emits_bright_light emits_low_light --set bright_light_distance#0 low_light_distance#0|Torch,--on has_bright_light_vision emits_bright_light --set bright_light_distance#20 }
?{IsNPC|No, --set bar1_link|fortune bar2_link|toughness_bonus bar3_link|Wounds -off showplayers_bar2 showplayers_bar1  showplayers_bar3|Yes, --set bar1_link|none bar2_link|none bar3_link|none }
  --set defaulttoken
}}


January 21 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Looks like you have an extra _ here:

--set_night_vision_distance#20

Should be:

--set night_vision_distance#20

Haven't tried it, that's just what I spotted in my phone.

January 21 (4 years ago)

I'm having a hard time for some reason (Mostly due to limited understanding of macros most likely) 
Of getting a Roll Queries macro to work that lets my players resize their tokens. 

!token-mod --set width|25ft height|35ft

But i'm having a hard time wrapping my head around it. :/ 
Expesh when it comes to getting it so I can just put in the number and it auto adds the ft to it. Although i guess i could just have players put that in themselves worse case. Wish i could get it to scale and just change the height with that in mind.


January 21 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Try this:

!token-mod --set scale|?{Size in feet}ft

Scale is the same as setting height and width to the same thing.

When you put a ?{a query} into a macro, it will get replaced by whatever you answer with, so the above, if you typed 25 would end up as:

!token-mod --set scale|25ft
January 21 (4 years ago)


The Aaron said:

Try this:

!token-mod --set scale|?{Size in feet}ft

Scale is the same as setting height and width to the same thing.

When you put a ?{a query} into a macro, it will get replaced by whatever you answer with, so the above, if you typed 25 would end up as:

!token-mod --set scale|25ft

Thank you very much. Worked great ^__^ Been loving the Token mod btw. Use it all the time. 


January 21 (4 years ago)

Edited January 21 (4 years ago)

Hi The Aaron! So I'm still unsure how to macro a blind. How do I switch off the token from "has vision"?

I've tried

!token-mod {{

--off

   has_vision

}}

But it doesn't work. I've also tried

!token-mod {{

--off
    has_bright_light_vision
    has_dim_light_vision

}}

But it only shuts off bright light, and I can still see dim light.

January 22 (4 years ago)

Edited January 22 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

For UDL, this is a good way:

!token-mod {{
 --on
    has_limit_field_of_vision
    has_limit_field_of_night_vision
  --set
    limit_field_of_vision_total|0
    limit_field_of_night_vision_total|0
}}
For LDL, this works:
!token-mod {{
  --set
    light_losangle|0
}}

The nice thing about this method (0º field of view) is that they are still bound by walls, and they can still see their token, they just can't see anything else.

January 22 (4 years ago)


The Aaron said:

For UDL, this is a good way:

!token-mod {{
 --on
    has_limit_field_of_vision
    has_limit_field_of_night_vision
  --set
    limit_field_of_vision_total|0
    limit_field_of_night_vision_total|0
}}
For LDL, this works:
!token-mod {{
  --set
    light_losangle|0
}}

The nice thing about this method (0º field of view) is that they are still bound by walls, and they can still see their token, they just can't see anything else.


You're the man! Thanks!! :)

January 22 (4 years ago)

Hi The Aaron 

I apologize if you've already addressed this, but I'm new to Roll20 and have ben setting up my campaign on here so my players can enjoy this VTT instead of looking through the camera on my phone at my badly drawn maps and mini's. As I joined about a week and a half ago on one of my set up sessions I had an offer to update to "Updated Dynamic Lighting". Today I came across a video on YT showing your fantastic API script (shameless creeping). I've tried to run it on my campaign nut it's not working. 

Am I being a complete DULLARD or does it not work on the Updated Dynamic Lighting yet? I'm not getting any errors showing on the API scripts page 

January 22 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

It should work pretty well for UDL, but UDL is pretty new and there are some things that are still broken on Roll20's side.  The settings for UDL are different than LDL, so if you've found some macros out on the web, they might be for LDL and need adjusting.  If you want to post some commands you're trying to use, we can try and adjust them for UDL, if that's the problem.

January 23 (4 years ago)

Hello everyone,

Sorry if this is a stupid question, but is it possible to set bar1, bar2 and bar3 to the values set in char sheet attributes but without linking them?

January 23 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

You can certainly set them manually like:

!token-mod {{
  --set
    bar1_current|@{SomeChar|hp}
    bar1_max|@{SomeChar|hp|max}
    bar2_current|@{SomeChar|ac}
    bar3_current|@{SomeChar|speed}
}}
January 23 (4 years ago)

Yeah, thanks, but is it possible to somehow get the charsheet name from represent character value instead of manually editing @{charname|hp} ?

The Aaron said:

You can certainly set them manually like:

!token-mod {{
  --set
    bar1_current|@{SomeChar|hp}
    bar1_max|@{SomeChar|hp|max}
    bar2_current|@{SomeChar|ac}
    bar3_current|@{SomeChar|speed}
}}




January 23 (4 years ago)

Edited January 23 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

This would work:

!token-mod {{
  --set
    bar1_current|@{selected|hp}
    bar1_max|@{selected|hp|max}
bar2_current|@{selected|ac}
bar3_current|@{selected|speed}
}}


January 23 (4 years ago)

Oh my god! Thank you very much. I was so over complicating things. :) I was trying to do it like this:

!token-mod {{
--set
bar1_current|@{selected|character_name|hp}
bar1_max|@{selected|character_name|hp|max}
}}

The Aaron said:

This would work:

!token-mod {{
  --set
    bar1_current|@{selected|hp}
    bar1_max|@{selected|hp|max}
bar2_current|@{selected|ac}
bar3_current|@{selected|speed}
}}





January 23 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

No problem! Sometimes it's hard to see the forest for the trees, to be sure. =D

January 24 (4 years ago)


The Aaron said:

It should work pretty well for UDL, but UDL is pretty new and there are some things that are still broken on Roll20's side.  The settings for UDL are different than LDL, so if you've found some macros out on the web, they might be for LDL and need adjusting.  If you want to post some commands you're trying to use, we can try and adjust them for UDL, if that's the problem.


I got it to work by setting up the info on Legacy Lighting and avoiding the updated Dynamic Lighting for now

January 27 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

I hate to say it, but that's probably the best approach for now.

January 30 (4 years ago)

I'm not able to get

bar1_max|@{selected|hp|max}

to work. Whenever I try it says "No attribute was found for @{selected|hp__max}"

I'm trying to get an entire monster build into a macro, as

!token-mod {{

    --set

    bar1_link|

    bar2_link|npc_ac

    bar3_link|

    showname|yes

    bar1_value|

    bar1_max|

    bar2_value|@{selected|npc_ac}

    bar2_max|@{selected|npc_ac}

    bar3_value|@{selected|hp}

    bar3_max|@{selected|hp|max}

    showplayers_bar3

    name|"@{selected|character_name} %%NUMBERED%%"

    token_name|"@{selected|character_name} %%NUMBERED%%"

    --set defaulttoken

}}

January 30 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter
That's peculiar. Where does that message show up, in chat?  Are you on the Dev server or production? What other scripts do you have installed?  Also, what browser are you using?
January 30 (4 years ago)

Edited January 30 (4 years ago)

The message shows up in chat. I'm about 90% sure I'm on the production server, as I've never actively tried to be on the Dev server. I have Token Name Number, Roll20 Audio Master, TokenMod, Group Initiative, Token Action Maker, StatusInfo, and Change Token Name. Based on you asking, I switched from Mozillia to Chrome and it works better, but still not perfect. I don't get the error message, but it also won't fill in the current HP.

I don't want to roll for HP for each monster, just have the default HP set. I see that in Attributes there isn't anything filled in for HP on the character sheet where I would expect it to be, and I can't find an Attribute that lines up with it.

I'm using the 5e Roll20 sheet.

I was under the impression  that linking hp for monsters is a bad thing because then if you change one monster’s hp (say from taking damage) then it would affect all of the tokens of that monster. 

January 30 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Try taking the ! off the front and running it. Post a screenshot of the results.

January 30 (4 years ago)

I've solved the problem so far as I see it by changing both bar3_value and bar3_max to hp|max and it's doing what it's supposed to. I don't know if that will conflict or cause problems down the line but so far so good?

January 30 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

I suppose as long as you got it working, then good enough!

January 30 (4 years ago)

I'm encountering a problem using @{selected}. If I highlight more than 1 token and attempt to execute my macro, it applies one token's information to all tokens. Is there a way to have a group selected and then have the tokenmod affect each token individually?

January 30 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

There isn't currently, I'm afraid.  It's on my list to figure out a way to do that, but hasn't gotten done yet.