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.

September 26 (5 years ago)

Hey Aaron, I was wondering if you ever did anything with this:

September 26 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Not yet. Man, was that really a year ago? Time moves so quickly of late...

September 26 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

I'd forgotten all about that. I think we have actually discussed that recently. In regards to generating hit points on tokens, maybe?

September 26 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Yeah, agree, seems like a month or so ago. 

September 26 (5 years ago)

Hey, I am having an issue and I wonder if there is a work around. I have this macro to try to speed up things when i get a token 

!token-mod {{
--set 
          width|1u 
          height|1u
          represents|?{Character}
          name|?{name}
          showname|yes
          showplayers_name|yes
          
}}

The problem comes when I try to use more than 2 names in the same checkbox. It only writes the first one or when i try to add a character that has two names. For example if I want to name a character Ulfred Pflaume, only Ulfred is added to the token and the last name just disappear. Is not like a huge problem but is quite annoying since I have to edit the token after. Is this a roll20 thing or can something be done with the script? 

September 26 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Try this:

!token-mod {{
--set 
          width|1u 
          height|1u
          represents|?{Character}
          name|"?{name}"
          showname|yes
          showplayers_name|yes
          
}}


September 26 (5 years ago)

Edited September 26 (5 years ago)

Hey guys, I was hoping someone could help me with the code to change the "bar location" the default for modules is above and I like bottom overlapping... I'd like to mass change tokens on the pages to fit my preference. Can Token Mod change the bar location? I didn't see it in the documentation but might have missed it?

**EDIT**

Oh, so it seems that you can set up your default settings then ingame settings you can apply default settings from the "Experimental Features" section at bottom. https://app.roll20.net/forum/post/7412194/tokenmod-and-the-new-bar-positioning/?pageforid=7412401#post-7412401

September 26 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

That's the only way at the moment. The bar position is not touchable by the API. This has been requested a number of times. Also be aware, since the API cannot affect it, the defaulttoken command will reset the bar position. This fix has also been requested of the dev team.

September 26 (5 years ago)

Thanks Keith! You are always so helpful :)

September 26 (5 years ago)

Edited September 26 (5 years ago)


The Aaron said:

Not yet. Man, was that really a year ago? Time moves so quickly of late...


IKR?  But yeah, I went scrolling back through old posts on the thread looking for something and thought I'd ask about that one once I came across it.  It's on page 8 here ...

Did you and Jakob ever get together (entmoot?) and see if you could apply something similar to his strategies?  I tend to use the two together (Tokenmod + ChatSetAttr APIs, for the uninitiated) in some macros, it'd be nice to see both sharing the same types of workaround syntax ... as long as it didn't break existing macros.

As far as I'm concerned, you have had a lot on your hands with Roll20 doing alot to their platform redesigns, so its totally forgivable to miss some stuff you were planning.  That total rework sent a lot of APIs rushing to restore their function - and some are still quite broken (some authors having abandoned all their works here on Roll20, or are taking extremely long breaks from it).  At least you're still here plugging away at making an up-to-date API for us all to enjoy, and expanding on its function all the while...

September 27 (5 years ago)

Edited September 27 (5 years ago)

The following reports 0 always, irregardless of the fact that it is a number value ...

!token-mod {{
--ids
-Lpkh5ZRJjzLH40cIcwR
--set
currentside|4

--current-page
--ignore-selected
--report
gm:control|"{name} current side number is {currentside:change}..."
}}
September 27 (5 years ago)

thx you kurt, is working perfect now :)

September 27 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter


Wolf Thunderspirit said:

The following reports 0 always, irregardless of the fact that it is a number value ...

!token-mod {{
--ids
-Lpkh5ZRJjzLH40cIcwR
--set
currentside|4

--current-page
--ignore-selected
--report
gm:control|"{name} current side number is {currentside:change}..."
}}

Try just {currentside}.  :change would be 0 if you changed to the same side you're currently on. 


September 30 (5 years ago)

Hey Aaron,

I am looking into TokenMod for multiple things but there is a couple things that maybe you can help me understand. I've come across this site where the person uses TokenMod to do some nifty things with Macros and I've tried them out and nothing seems to happen.

Website: [ Roll20 Player Controlled Condition Macros ]

Lets use one of the macros as an example...

/em has blessed you…
&{template:npcaction} {{name=Tagged: Blessed}} {{description=You bless up to three creatures of your choice within range.
Whenever a target makes an attack roll or a saving throw before the spell ends, the target can roll a d4 and add the number rolled to the attack roll or saving throw.
At Higher Levels. When you cast this spell using a spell slot of 2nd level or higher, you can target one additional creature for each slot level above 1st. }}
!token-mod –ids @{target|1|token_id} @{target|2|token_id} @{target|3|token_id} –set statusmarkers|blue|angel-outfit
[Additional Creature(s)? ](!
#y-Tagged-Add-Bless)

After using the macro, I get prompted to click the 3 targets so bless can be used but after clicking the 3 targets no status marker or color is put on the token. So I am baffled if there is something I am doing wrong..

September 30 (5 years ago)

Edited September 30 (5 years ago)

I'm not that great with code, but try replacing that one line with the text below..

!token-mod --ids @{target|1|token_id} @{target|2|token_id} @{target|3|token_id} --set statusmarkers|blue|angel-outfit

It looks like it was missing a few '-' bits...

EDIT: I've looked at that same website. I'm guessing that the HTML editor used to build the website actually turned '--' into an '–'. I'm guessing the author never realised. - If you take a look at their screenshot near the top of the page, you can see that their code has '--' showing.

That said, I may be wildly wrong, but that said... my suggested code works ok for me :)

September 30 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Many text editors replace -- with —, so that may be a problem.  Also, be sure if players are going to use this that you turn on Players Can IDS in the settings, or toggle it with this command:

!token-mod --config players-can-ids
September 30 (5 years ago)
Joe
Pro


The Aaron said:

Many text editors replace -- with —, so that may be a problem. 

That substitution consistently drives me nuts when writing macros! :-P LOL


September 30 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

I could probably detect and fix that on submission, but if you used — in the rest of your message, those would cause issues.  I could certainly find it in macros and abilities and give warnings, or if I found no commands, give a whisper about it.  Hmm.... I really need to write a unified command line parser...

September 30 (5 years ago)

Holy Crap ... That fixed everything! ... something so simple as to changing it to "--" thank you so much!

October 01 (5 years ago)


JinDaKiD said:

Holy Crap ... That fixed everything! ... something so simple as to changing it to "--" thank you so much!


If possible, notify the original macro author to edit his code and correct it.  Not doing so perpetuates the problem for others, as it did for you.


Wolf Thunderspirit said:


JinDaKiD said:

Holy Crap ... That fixed everything! ... something so simple as to changing it to "--" thank you so much!


If possible, notify the original macro author to edit his code and correct it.  Not doing so perpetuates the problem for others, as it did for you.


Agreed! Thank you for the heads up.

November 02 (5 years ago)

Edited November 02 (5 years ago)

Hi, does anyone have a script for changing the purchased Roll20 Module Token Bar settings? Because I do not like their default bar settings, they can be seen below on the Token Baphomet:



I'm looking for a script to change the token bar values to the following token Duke Thalamra Vanthampur (Bar 3 is their hp). And also to make it their default token, as I have to update over 200+ tokens manually to the way I like them, and that's not fun. (I would like their darkvision untouched and left the way it is) I only want to update the bar settings.



TLDR I don't want tokens like the purchased default Baphomet.
I want them like Duke Thalamra Vanthampur. :)

November 02 (5 years ago)

You can change the default setting under game settings to link the bars, then apply the default setting under the cog in game. There should be a button at the bottom next.

November 02 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

He doesnt want to link the HP bar (for example), he wants to copy the HP value from the character sheet and put it in the bar, without linking the bar.

Garrad, if you read the documentation for tokenmod, it explains how to do this.

November 03 (5 years ago)


Kilter said:

You can change the default setting under game settings to link the bars, then apply the default setting under the cog in game. There should be a button at the bottom next.

Thanks Kilter, that's actually really handy to know! :)


GiGs said:

He doesnt want to link the HP bar (for example), he wants to copy the HP value from the character sheet and put it in the bar, without linking the bar.

Garrad, if you read the documentation for tokenmod, it explains how to do this.

Correct GiGs! And to be honest I saw the lengthy documentation and thought it would be quicker and likely that someone else had already done something similar to this.  I Posted to save my time, but I guess I'll have to figure it out on my own anyway :P



November 03 (5 years ago)

Edited November 03 (5 years ago)

Correct GiGs! And to be honest I saw the lengthy documentation and thought it would be quicker and likely that someone else had already done something similar to this.  I Posted to save my time, but I guess I'll have to figure it out on my own anyway :P

Now now - in life there are no shortcuts.  But is it a matter of not knowing how to, or laziness/ procrastination?  If the former, I'm sure there would be many willing to help, even me if I could understand what it is you hope to accomplish.  If the latter ... well ... you know.  I think if it is the latter, the best advice I ever heard was about teaching a man to fish .... Questions about how to build macros from APIs will always come up if you don't learn how to be independent.

But yes, the default changes make for the best method of changing the way your output looks.  The 5e Shaped Sheet has a configuration utility (!shaped-config) in it that can also change which bars are used for what, then you can simply run !shaped-defaults to make sure it is in line with your settings, though when the sheet is converted over, it should do that automatically.  But to ask Token Mod to do it would not really help you as much as the Roll20 App Defaults in Game Settings, Unless you wish to go through the painful process of doing each individually.  Or is there a group of tokens you can work with all at once with the selected token method?

November 18 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Update v0.8.46 -- Fixed a bug where setting scalewidthheightleft, or top would result in the selection border and the area where a token could be selected being broken.  (Thanks Cameron D. )  


November 21 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Update v0.8.47 -- Enhanced --bar1_reset| and its brethren to use the max value on a freshly linked bar attribute.  Now this works as expected (Thanks Cameron D. ):

!token-mod {{
  --set
    represents|Bob
    bar1_link|hp
    bar1_reset|
}}

November 28 (5 years ago)

Is there a way to set the text overlay on a bar to see everyone?

November 28 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

You mean the "18/27" part?  Not yet, waiting on an interface from Roll20 to do that from the API. 

November 29 (5 years ago)

Yes. That is what I meant. Thank you.

December 02 (5 years ago)

Edited December 04 (5 years ago)

I've got an error in the API every time I set a marker on a token (PC and NPC) and it breaks the API in combat sometimes, someone knows why ?

The command was just : !token-mod --set statusmarkers#!stopwatch


EDIT:

Found solution! See post for answer:


December 03 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

That's bizarre. I'll have to try and duplicate that. Does it still do it when you disable all other scripts?

December 03 (5 years ago)

Edited December 04 (5 years ago)

StatusInfo seems to be the culprit, the error does not appear when it is disabled, it just displays the info of the condition related to the marker, strange.


EDIT:

Found solution! See post for answer:

December 03 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

I'm glad it wasn't TokenMod causing the issue. I'm at a convention in Orlando right now, but I'll try to take a look at why StatusInfo is causing the issue. 

December 03 (5 years ago)

Edited December 04 (5 years ago)

Found solution! See post for answer:

https://app.roll20.net/forum/post/7955603/statusinfo-getting-error-no-attribute-or-sheet-field-found-for-character-id-in-api-when-applying-markers

December 14 (5 years ago)

Hey, I'm having a weird issue where TokenMod is installed, but none of the commands are working. I've removed it, readded it, etc. But still seems broken, not even the help command is showing up in chat. Was working perfectly the other week. I have no idea what's going on.

December 14 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Try refreshing the api and game pages.

Are there any errors in the api log? In the javascript console log?

Are all other scripts working?

Try disabling all other scripts and see if it starts working. If it does, there is a conflict in one of the others.

Are you using the 1-click version?  If so, try manually installing it. 

December 15 (5 years ago)

Edited December 15 (5 years ago)

The Aaron, when the Custom Tokens markers are a thing. Will you be able to add it to tokenmod?

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

Heck yeah you will!  I've already started on the code change. I intend to have a new version that supports both the old and new way ready for the api merge Tuesday. 

December 15 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

My hero!

December 15 (5 years ago)

Edited December 15 (5 years ago)


Danny C. said:

The Aaron, when the Custom Tokens markers are a thing. Will you be able to add it to tokenmod?


The Aaron said:

Heck yeah you will!  I've already started on the code change. I intend to have a new version that supports both the old and new way ready for the api merge Tuesday. 


keithcurtis said:

My hero!


+1 to that

Finally get a chance to use Stephen Lindberg's Custom Status Markers without needing to use a complicated API!

December 15 (5 years ago)

Hey, didn't have any other scripts running and the output console seemed to be stuck (was just a single line). I went ahead and removed the script  copied the game and reinstalled it there. Seems to be working fine now. Something must've went wobbly. Thanks for the help! :)

December 16 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Update 0.8.48 -- Added support for Custom Token Marker sets (Status Markers).  (Thanks keithcurtis)

Available Status Markers are displayed in the help and can be used just like before.  The only difference is that the names may not be unique (see mountains in the image).  If there is more than one status marker with the same name, you can use the tag (the value in [ ] ):

!token-mod --set statusmarkers|+mountains:3

Adds the mountains:1990 status marker to the selected tokens with the number 3 on it.

!token-mod --set statusmarkers|+mountains::1991:3

Adds the mountains::1991 status marker to the selected tokens with the number 3 on it.

Custom Token Marker sets are still in development, so please give this a try on Dev and see if you run into any problems.


Github: https://github.com/shdwjk/Roll20API/blob/master/TokenMod/TokenMod.js


The Aaron said:

Update 0.8.48 -- Added support for Custom Token Marker sets (Status Markers).  (Thanks keithcurtis)

Available Status Markers are displayed in the help and can be used just like before.  The only difference is that the names may not be unique (see mountains in the image).  If there is more than one status marker with the same name, you can use the tag (the value in [ ] ):

!token-mod --set statusmarkers|+mountains:3

Adds the mountains:1990 status marker to the selected tokens with the number 3 on it.

!token-mod --set statusmarkers|+mountains::1991:3

Adds the mountains::1991 status marker to the selected tokens with the number 3 on it.

Custom Token Marker sets are still in development, so please give this a try on Dev and see if you run into any problems.


Github: https://github.com/shdwjk/Roll20API/blob/master/TokenMod/TokenMod.js


Thanks for this, Aaron. Will this update eventually be in the one-click install?

December 17 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

In fact, it should be there now!


The Aaron said:

In fact, it should be there now!


Whoo-hoo, thank you!

January 05 (5 years ago)

Edited January 05 (5 years ago)

Is there a command to reveal a token's HP values to players i.e. change the HP bar setting to "Visible to everyone"?

January 05 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

This should do it:

!token-mod --on showplayers_bar1

Assuming you are using bar1 for HP. Adjust as needed.

January 05 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

You can find them in the Boolean Arguments section of the help.

Here are some of the ones that might interest you:

  • 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


You can use them as Keith showed above:

!token-mod --on showplayers_bar1 showplayers_bar2 showplayers_bar3

or

!token-mod {{
  --on
    showplayers_bar1
    showplayers_bar2
    showplayers_bar3
}}

You can also use the set command, and specify on or off:

!token-mod {{
  --set
    showplayers_bar1|on
    showplayers_bar2|1
    showplayers_bar3|true
}}

Which might be useful if you find you want to toggle it with an option:

!token-mod {{
  --set
    showplayers_bar1|?{show|on|off}
    showplayers_bar2|?{show}
    showplayers_bar3|?{show}
}}