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 01 (3 years ago)

@Jarren: thanks for the clarification. Learned something new again :-)

November 01 (3 years ago)

Edited November 01 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter


Will a.
 said:

This is a heck of a thread, is there any capabilities with token mod, or any other script to have conditionals. for example: if health(bar 3) is below a threshold(constant) add a dice(Roll)?


I believe that Script Cards contains conditionals, but I don't use it.

November 01 (3 years ago)


Will a. said:

This is a heck of a thread, is there any capabilities with token mod, or any other script to have conditionals. for example: if health(bar 3) is below a threshold(constant) add a dice(Roll)?


Also on top of this, does Reusing rolls through $[[0]] calls not work with token mod or is there a way i should be formatting it?

November 01 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter


Will a. said:


Will a. said:

This is a heck of a thread, is there any capabilities with token mod, or any other script to have conditionals. for example: if health(bar 3) is below a threshold(constant) add a dice(Roll)?


Also on top of this, does Reusing rolls through $[[0]] calls not work with token mod or is there a way i should be formatting it?

IIRC, re-using rolls is generally a display-only feature. But there my be some very specific exceptions. This page might answer your questions.

November 01 (3 years ago)
timmaugh
Pro
API Scripter


Will a. said:

This is a heck of a thread, is there any capabilities with token mod, or any other script to have conditionals. for example: if health(bar 3) is below a threshold(constant) add a dice(Roll)?

I know Keith mentioned ScriptCards. Also, APILogic, a metascript that can be plugged into another script's command line.

APIL works from the perspective of what can be recognized at the time APIL runs, evaluating the conditionals, and then leaving the command line in a particular disposition for the intended-recipient script to take action on. The text within the boundaries of the conditional is what is left IN the command line if the conditional passes evaluation.

So, a test of bar3 being below some value (lets say, 5), then add a dice roll... the token-mod line could look like:

!token-mod --set bar3|+[[1d20]]

Then you'd ask how much of that is conditional on the value of bar3. Since that is the only thing we're setting, it's really everything. So we wrap that in the conditional parts of APIL:

!{& if @{selected|bar3} < 5 }token-mod --set bar3|+[[1d20]]{&end}

If there were MORE things you wanted to do in token-mod (like set other properties), then you might only want to conditionalize the single property setting:

!token-mod --set name|Potato {& if @{selected|bar3 < 5}bar3|+[[1d20]]{&end}

There are more examples in the APILogic thread, including nesting conditionals and complex AND and/or OR constructions.


November 02 (3 years ago)

Edited November 02 (3 years ago)

!token-mod --set tooltip|@{selected|Cond} works, but how do I combine multipple atttributes and text together, to be set in tooltip together.

Such as:

!token-mod --set tooltip|"@{selected|Cond} and more"

or !token-mod --set tooltip|@{selected|Cond},@{selected|Cond2}


November 02 (3 years ago)
timmaugh
Pro
API Scripter

Pretty much like your first example... if there is a space, you have to use quotes. Remember, though, that we can't really style the tooltip, so whatever you put in the tooltip will look like a string of text.

November 03 (3 years ago)

!token-mod --set show_tooltip|no

Does not seem to work. 'yes' turns it on but I cant turn it off (only manually).

November 03 (3 years ago)
Andrew R.
Pro
Sheet Author

I can report that this works:

!token-mod --on show_tooltip
!token-mod --off show_tooltip
November 03 (3 years ago)

Andrew R. said:

I can report that this works:

!token-mod --on show_tooltip
!token-mod --off show_tooltip

On works, but off does not. I do have lots of other scripts active, so maybe a conflict somewhere. Weird, but a minor annoyance.

November 04 (3 years ago)
Finderski
Pro
Sheet Author
Compendium Curator

Is there a way to insert a line break in a tool tip?  I'm currently using:

!token-mod {{ 
    --set 
        tooltip|"Parry @{selected|parryCur} Toughness @{selected|toughnesscur} (@{selected|toughnessArmor})" 
    --on
        show_tooltip
}} 

I'd love to have a line break right before Toughness. I've tried: hitting enter in the macro itself (didn't think it would work, since you can have line breaks for the command anyway), \n, &#13; and <br>. But none of those work...

November 04 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

it looks like the displayed text is pretty sanitized. I haven't found a method either.

November 22 (3 years ago)
Joe
Pro

For those of you who want to move dynamic lighting easily (eg attached to a token), check out the Dynamic Light Recorder script: https://github.com/symposion/roll20-api-scripts/tree/master/DynamicLightRecorder

November 23 (3 years ago)

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?

December 08 (3 years ago)
Mike W.
Pro
Sheet Author


Kaspar K. said:

Andrew R. said:

I can report that this works:

!token-mod --on show_tooltip
!token-mod --off show_tooltip

On works, but off does not. I do have lots of other scripts active, so maybe a conflict somewhere. Weird, but a minor annoyance.

I too cannot get the show_tooltip to turn off. I tried:

!token-mod --off show_tooltip
!token-mod --set show_tooltip|off

Neither works however the 'ON' works with both. 

I tried this on a test game where Tokenmod is the only script loaded.



December 08 (3 years ago)

Edited December 08 (3 years ago)
Mike W.
Pro
Sheet Author

There is another issue I am also having. I have a macro men using Tokenmod that allows me to change a PCs sight from Basic to Peripheral to 360 - works fine. It also allows me to set Darkvision, Nightvision, Infravision, and Ultravision - also works fine. Thus I can set a token to Peripheral vision and give that token Darkvision as well. Then, for example, if I change the token to Nightvision, although the settings show on the token, the settings do not take effect until I then click Save Settings within the token itself. It appears that what I need is for Tokenmod to have a Save Settings switch for Dynamic Lighting.

December 08 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter


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




December 08 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

When I implemented this, there was a disparity between what the api would set abs what the UI would show.  If I remember correctly, you'd have to set it off twice before it would work correctly, or something similar. I'll try to check this again.

Mike W. said:


Kaspar K. said:

Andrew R. said:

I can report that this works:

!token-mod --on show_tooltip
!token-mod --off show_tooltip

On works, but off does not. I do have lots of other scripts active, so maybe a conflict somewhere. Weird, but a minor annoyance.

I too cannot get the show_tooltip to turn off. I tried:

!token-mod --off show_tooltip
!token-mod --set show_tooltip|off

Neither works however the 'ON' works with both. 

I tried this on a test game where Tokenmod is the only script loaded.






December 08 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Today's patch is supposed to fix this issue, is it still persisting?

Mike W. said:

There is another issue I am also having. I have a macro men using Tokenmod that allows me to change a PCs sight from Basic to Peripheral to 360 - works fine. It also allows me to set Darkvision, Nightvision, Infravision, and Ultravision - also works fine. Thus I can set a token to Peripheral vision and give that token Darkvision as well. Then, for example, if I change the token to Nightvision, although the settings show on the token, the settings do not take effect until I then click Save Settings within the token itself. It appears that what I need is for Tokenmod to have a Save Settings switch for Dynamic Lighting.




December 08 (3 years ago)

Is there a way to append text to a tooltip using --set tooltip command? Currently, it overwrites anything already in the tooltip.

December 08 (3 years ago)
timmaugh
Pro
API Scripter


Doug E. said:

Is there a way to append text to a tooltip using --set tooltip command? Currently, it overwrites anything already in the tooltip.

If not natively in TokenMod, then by using a Fetch construction:

!token-mod --set tooltip|"@(selected.tooltip); stuff you want to add"

Just don't put any TokenMod-breaking key combinations in there... like a double hyphen.


December 08 (3 years ago)
Mike W.
Pro
Sheet Author

Doing it twice did not turn it off either.

The Aaron said:

When I implemented this, there was a disparity between what the api would set abs what the UI would show.  If I remember correctly, you'd have to set it off twice before it would work correctly, or something similar. I'll try to check this again.

Mike W. said:


Kaspar K. said:

Andrew R. said:

I can report that this works:

!token-mod --on show_tooltip
!token-mod --off show_tooltip

On works, but off does not. I do have lots of other scripts active, so maybe a conflict somewhere. Weird, but a minor annoyance.

I too cannot get the show_tooltip to turn off. I tried:

!token-mod --off show_tooltip
!token-mod --set show_tooltip|off

Neither works however the 'ON' works with both. 

I tried this on a test game where Tokenmod is the only script loaded.









December 08 (3 years ago)

Edited December 08 (3 years ago)
Mike W.
Pro
Sheet Author

I just tested this again today and it is still not saving or implementing all the time..

The Aaron said:

Today's patch is supposed to fix this issue, is it still persisting?

Mike W. said:

There is another issue I am also having. I have a macro men using Tokenmod that allows me to change a PCs sight from Basic to Peripheral to 360 - works fine. It also allows me to set Darkvision, Nightvision, Infravision, and Ultravision - also works fine. Thus I can set a token to Peripheral vision and give that token Darkvision as well. Then, for example, if I change the token to Nightvision, although the settings show on the token, the settings do not take effect until I then click Save Settings within the token itself. It appears that what I need is for Tokenmod to have a Save Settings switch for Dynamic Lighting.







December 09 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Ug.  I've confirmed that the patch did not fix it. =(

Mike W. said:

I just tested this again today and it is still not saving or implementing all the time..

The Aaron said:

Today's patch is supposed to fix this issue, is it still persisting?

Mike W. said:

There is another issue I am also having. I have a macro men using Tokenmod that allows me to change a PCs sight from Basic to Peripheral to 360 - works fine. It also allows me to set Darkvision, Nightvision, Infravision, and Ultravision - also works fine. Thus I can set a token to Peripheral vision and give that token Darkvision as well. Then, for example, if I change the token to Nightvision, although the settings show on the token, the settings do not take effect until I then click Save Settings within the token itself. It appears that what I need is for Tokenmod to have a Save Settings switch for Dynamic Lighting.










December 09 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Hmm.  It's working fine for me.  Do you want to PM me an invite to your game and GM me and I can come check it out?

Mike W. said:

Doing it twice did not turn it off either.

December 09 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter


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.

December 09 (3 years ago)
Mike W.
Pro
Sheet Author

The Aaron

Could you show me what command(s) you are using ad how you are using them to achieve this? I assume I am probably doign it wrong.


The Aaron said:

Hmm.  It's working fine for me.  Do you want to PM me an invite to your game and GM me and I can come check it out?

Mike W. said:

Doing it twice did not turn it off either.




December 09 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

I'm literally just using these:

!token-mod --on show_tooltip
!token-mod --off show_tooltip

With the token selected.  Do you have the token selected?  The other thing is, do you have tooltip text?  And finally, how are you verifying this works, are you hovering through token to get the tooltip? Or are you looking at the checkbox in the UI? (That will be wrong, probably)



December 09 (3 years ago)
Mike W.
Pro
Sheet Author

Now this is strange, when I used the code you showed me - it works fine. Also now my script is working with either way to shut off the tooltip. I made no changes at all.
Thanks again for helping me out.


On a side note and FYI: If your use the tooltip command in a Journal Command Button in a Handout and have a colon as part of the tooltip text, you must use the HTML Entity &colon; in order to get that colon to be recognized and used.
For example, I had a tooltip that said "For Partial Darkness: User Darkness penalties.". The tooltip only showed "For Partial Darkness&" and nothing else. Replacing the 'colon' with 
&colon; fixed the issue.

The Aaron said:

I'm literally just using these:

!token-mod --on show_tooltip
!token-mod --off show_tooltip

With the token selected.  Do you have the token selected?  The other thing is, do you have tooltip text?  And finally, how are you verifying this works, are you hovering through token to get the tooltip? Or are you looking at the checkbox in the UI? (That will be wrong, probably)






December 09 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

API Buttons use the same syntax as url links. The Roll20 chat parser is simplistic and will treat a thing with a : in it as a URL. 

December 10 (3 years ago)
Mike W.
Pro
Sheet Author

Thanks for the information, I knew that but for some reason my mind did not click today - Must be the weather!

The Aaron said:

API Buttons use the same syntax as url links. The Roll20 chat parser is simplistic and will treat a thing with a : in it as a URL. 




December 10 (3 years ago)

Related question.  These are working for me, but they don't seem to persist for the default token.  I turn on the tooltips, update the default token, but when I drag a new token out, the tool tips are off again.  It's not really token-mod related because I can manually turn them on and it still does not work.

Token with Tool Tip on and set to the default token for the character

New token Dragged on, Tool Tip is off



Looks like a bug in the tool tips honestly.  Wonder if there is a way to write a script that would turn the tool tips on for a new token when it is dropped onto the map?  I am looking to replace showing nameplates with using tool tips for names to help with screen clutter.

The Aaron said:

I'm literally just using these:

!token-mod --on show_tooltip
!token-mod --off show_tooltip

With the token selected.  Do you have the token selected?  The other thing is, do you have tooltip text?  And finally, how are you verifying this works, are you hovering through token to get the tooltip? Or are you looking at the checkbox in the UI? (That will be wrong, probably)






December 10 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

It sounds like you just need to set the token back as the default token for that character:

!token-mod --set defaulttoken


December 10 (3 years ago)
Andrew R.
Pro
Sheet Author

Yes, that's a bug with the current tooltips implementation. I spotted and reported it when tooltips were announced. I hope it'll get fixed sometime.

I'm using tooltips to show the 13th Age defenses, so I turn the tooltip on while prepping the session. No biggie.

!token-mod --on show_tooltip
December 10 (3 years ago)
Mike W.
Pro
Sheet Author

Any luck yet at fixing this?

The Aaron said:

Ug.  I've confirmed that the patch did not fix it. =(

Mike W. said:

I just tested this again today and it is still not saving or implementing all the time..

The Aaron said:

Today's patch is supposed to fix this issue, is it still persisting?

Mike W. said:

There is another issue I am also having. I have a macro men using Tokenmod that allows me to change a PCs sight from Basic to Peripheral to 360 - works fine. It also allows me to set Darkvision, Nightvision, Infravision, and Ultravision - also works fine. Thus I can set a token to Peripheral vision and give that token Darkvision as well. Then, for example, if I change the token to Nightvision, although the settings show on the token, the settings do not take effect until I then click Save Settings within the token itself. It appears that what I need is for Tokenmod to have a Save Settings switch for Dynamic Lighting.













December 10 (3 years ago)
Andrew R.
Pro
Sheet Author


The Aaron said:

It sounds like you just need to set the token back as the default token for that character

That doesn't work for my 13th Age monster tokens setup as MOOKS per the documentation. :-( 

My player's CHARACTER tokens don't use tooltips so far. They really appreciate the tooltips on the monsters, it speeds up play a lot. 

December 10 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Oh!?  Tooltip state isn't saved for default tokens!?!??  I'll verify that and then escalate to the Devs. 

December 10 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

This is on the Roll20 side, it's not a thing I can fix.

Mike W. said:

Any luck yet at fixing this?

December 11 (3 years ago)
Mike W.
Pro
Sheet Author

Ok thanks for looking into this.
Perhaps you could add a tokenmod command that activates the Save Changes, thus forcing it to do so?

The Aaron said:

This is on the Roll20 side, it's not a thing I can fix.

Mike W. said:

Any luck yet at fixing this?




December 11 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

The API doesn't have that kind of access. It's running on a server in the cloud, and only interacts with the backend. 

December 11 (3 years ago)

Edited December 11 (3 years ago)
Mike W.
Pro
Sheet Author

Well I guess I will have to live with that. Thanks.

The Aaron said:

The API doesn't have that kind of access. It's running on a server in the cloud, and only interacts with the backend. 




December 11 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter


The Aaron said:

Oh!?  Tooltip state isn't saved for default tokens!?!??  I'll verify that and then escalate to the Devs. 


Yup. It was reported at the time. Given the nature of the feature which felt like a Hacktoberfest sort of thing, I don't have high hopes of any change in functionality.

December 11 (3 years ago)

Edited December 11 (3 years ago)

Is there a way to set line breaks inside of a tooltip? 
Here is what I am working on to use on all my player characters.

!token-mod {{

  --set

    represents|@{Dave|character_id}

    name|"Dave"

    bar1_link|ac

    bar2_link|speed

    bar3_link|hp

    tooltip|"AC: @{selected|AC}; PP: @{selected|passive_wisdom}; Move Speed: @{selected|speed}; Save DC: @{selected|spell_save_dc}"

    defaulttoken

  --on 

    show_tooltip

}}


The tooltip works mostly as intended, what it shows is something along the lines of

AC: 21; PP: 19; MS:
45; Save DC: 17;

what i'd like is 
AC: 21;
PP: 19;
MS: 45;
Save DC: 17;


Also, is there any ways I can improve this, so that I don't have to change the names every time, perhaps a quarry in form of a drop down menu for both of the Name fields? That way I have one button that I can just press for setting up a token, without editing it each time.
And how can I also have it automatically grant basic vision, or night vison?

December 12 (3 years ago)
Andreas J.
Forum Champion
Sheet Author
Translator

Rob F. said:

Is there a way to set line breaks inside of a tooltip? 

Not currently, neither normally or with API. The Tooltip text is heavily sanitized, and doesn't allow any formatting right now. Hopefully that will change for later.

December 15 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Update v0.8.73 - Fixed a bug that crashed TokenMod when any message used an inline roll of a Tollable Table with no rows.  (Thanks Shane M. )

Additionally, I've changed TokenMod so it will do a better job of ignoring messages that aren't meant for it. =D

December 15 (3 years ago)
Andreas J.
Forum Champion
Sheet Author
Translator

Request: Minor QoL

  • Have token-mod respond in some way if you call just "!token-mod" without parameters. Simply replying with a short description, link to the TokenMod Handout & this forum thread, and mention of the !token-mod --help-command.
    • If you are troubleshooting APIs and stuff, it's nice if one could just simply verify if the API is alive with the command, instead of having to make some longer command.
    • For newer users/players in a game, it can be confusing if doing !token-mod does nothing, especially if they don't happen to recall/known !token-mod --help being the exact command.
  • Having it react to "!tokenmod"
    • Either with a reply saying what the correct command is, or outright treating !tokenmod same as !token-mod
  • Changing so "!token-mod --help" doesn't dump the whole documentation in the chat.
    • Either shorten so --help only gives the highlights + handout+forum+wiki links when called. Then have new command for dumping the full documentation in the chat. Or have this happen when !token-mod is called without parameters.
  • Handout/--help command giving link to the TokenMod-page, and this forum thread
    • Both contain more examples and help, so adding link to them as "additional sources" would make sense.
December 15 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

That's definitely on my list.  I can probably hit the first bullet (and perhaps the second), but the help rewrite is a larger task that I've been working on.

December 17 (3 years ago)

Edited December 17 (3 years ago)
Mike W.
Pro
Sheet Author

I am having issues with the following (All from chat as I am testing right now):

Emits Bright Light is off. Emits Low Light is off. Directional Light is 0.
I use this command: 

!token-mod --set emits_bright_light|on emits_low_light|on bright_light_distance|2 low_light_distance|5 has_directional_bright_light|on directional_bright_light_total|180
This sets all the fields, actually emits bright light but the light is 360°, even though the field on the token says 180°. The 180° does not take effect until I manually click "Save Changes" on the token.

Emits Bright Light is already on. Directional Light is off.

!token-mod – set has_directional_bright_light|on directional_bright_light_total|180
This does nothing.

I am stumped, what am I doing wrong here?

December 18 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

You are doing nothing wrong. The API does not respond correctly to that feature yet. Directional light and arc of vision require you to open and close the token settings at the very least before they take. 

December 18 (3 years ago)
Mike W.
Pro
Sheet Author

Thanks Keith
Do you have any idea when this will be addressed?