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 .
×
Advertisement Create a free account

[Script Update] TokenMod -- An interface to adjusting properties of a token from a macro or the chat area.

Thanks, that was driving me nuts
1599641910

Edited 1599642054
One question: is there a possibility to remove all statusmarkers with names starting with a certain text? Example : there are markers named "elevation5", "elevation10" and so on. Now I want to remove all markers beginning with "elevation". Is there a way? Use Case : A token has several statusmarkers set and they should be kept. I want to use a marker "elevation10" to tell that it's flying in a height of 10ft If the height changes to 20, I have to remove "elevation10" and set "elevation20" Of course I don't know prior to setting a new height what the last was. Therefore I want to remove all markers beginning with "elevation" and then set the new. I can't remove all markers because there are also some which shall be kept. Thanks in advance! PS: the idea to set the height so far is: !token-mod --set statusmarkers|elevation?{height} Bernd
1599653099
The Aaron
Forum Champion
API Scripter
No, but that's something I can probably add. I'll look into it. 
Just a question on this Aaron. I can't believe I'm only now exploring this API. Can this do group checks, group initiatives? etc? Or will it clash with those if I use those specific API's? Lastly, is there a list, a collection of example macro's for D&D 5e sheets using TokenMod? Common Tips and tricks of what to use for what?
1599851588
The Aaron
Forum Champion
API Scripter
It won't conflict with those other scripts. They are sprinkled all over the forum.&nbsp; You could start with a google search:&nbsp; <a href="https://www.google.com/search?q=site%3Aroll20.net+%22!token-mod%22&amp;oq=site%3Aroll20.net+%22!token-mod%22&amp;aqs=chrome..69i57j69i58.7789j0j7&amp;sourceid=chrome&amp;ie=UTF-8" rel="nofollow">https://www.google.com/search?q=site%3Aroll20.net+%22!token-mod%22&amp;oq=site%3Aroll20.net+%22!token-mod%22&amp;aqs=chrome..69i57j69i58.7789j0j7&amp;sourceid=chrome&amp;ie=UTF-8</a> Or ask about specific things you want to be able to do.
1599855993

Edited 1599856062
The Aaron said: It won't conflict with those other scripts. They are sprinkled all over the forum.&nbsp; You could start with a google search:&nbsp; <a href="https://www.google.com/search?q=site%3Aroll20.net+%22!token-mod%22&amp;oq=site%3Aroll20.net+%22!token-mod%22&amp;aqs=chrome..69i57j69i58.7789j0j7&amp;sourceid=chrome&amp;ie=UTF-8" rel="nofollow">https://www.google.com/search?q=site%3Aroll20.net+%22!token-mod%22&amp;oq=site%3Aroll20.net+%22!token-mod%22&amp;aqs=chrome..69i57j69i58.7789j0j7&amp;sourceid=chrome&amp;ie=UTF-8</a> Or ask about specific things you want to be able to do. Ok, I did do a google search and didn't see what I was looking for. Essentially what I'd like to do is have a breakdown like this: @keithCurtis's TokenMod Vision Macro: /w gm &amp;{template:npcaction} {{rname=Light &amp; Vision}} {{description=[Snuff](!token-mod --set light_otherplayers|off light_radius|0 light_dimradius|0 light_angle|360) | [Sight](!token-mod --on showname light_hassight light_angle|360) | [Blind](!token-mod --off showname light_hassight light_angle|360) | [Spot](!token-mod --set light_otherplayers|on light_radius|5 light_dimradius|0 light_hassight|on light_angle|360) | [GM](!token-mod --set light_otherplayers|off light_hassight|off light_radius|5 light_dimradius|5 light_angle|360) [Moonlight](!token-mod --set light_otherplayers|on light_radius|15 light_dimradius|=-15 light_angle|360) | [Starlight](!token-mod --set light_otherplayers|on light_radius|7 light_dimradius|=-15 light_angle|360) | [Touch](!token-mod --set light_otherplayers|on light_radius|4 light_dimradius|=-5 light_angle|360) [Candle](!token-mod --set light_otherplayers|on light_radius|5 light_dimradius|0 light_angle|360) | [Lamp](!token-mod --set light_otherplayers|on light_radius|30 light_dimradius|15 light_angle|360) | [Torch](!token-mod --set light_otherplayers|on light_radius|40 light_dimradius|20 light_angle|360) [Hooded Lantern](!token-mod --set light_otherplayers|on light_radius|60 light_dimradius|30 light_angle|360) | [Bullseye Lantern](!token-mod --set light_otherplayers|on light_radius|120 light_dimradius|60 light_angle|90) [Darkvision](!token-mod --set light_otherplayers|off light_hassight|on light_radius|60 light_dimradius|=-5 light_angle|360) | [DV90](!token-mod --set light_otherplayers|off light_hassight|on light_radius|95 light_dimradius|=-5 light_angle|360) | [DV120](!token-mod --set light_otherplayers|off light_hassight|on light_radius|125 light_dimradius|=-5 light_angle|360) | [*Light*](!token-mod --set light_otherplayers|on light_radius|40 light_dimradius|20 light_angle|360) | [*Daylight*](!token-mod --set light_otherplayers|on light_radius|120 light_dimradius|60 light_angle|360) | [*Faerie Fire*](!token-mod --set light_otherplayers|on light_radius|1 light_angle|3600 light_dimradius|0 statusmarkers|purple light_angle|360)}} But for the new Dynamic Lighting. I saw the forums, but I'm complete shit when it comes to programming, thus the hope that someone's already done this as a macro.
1600632393
I cant seem to find this, sorry if I am repeating something. First off, dang, The Aaron, you are awesomely helpful. Thank you for all the work you are doing. I have spent a couple pouring over all the different script info on the forums. Awesome. Disclaimer, I am very new to Macros and Srcipting, hopefully this is easy, seems like it should be. I would love a way to pull one single attribute value and plugging that into the Aura. It is related to range, but not as complex as this range band issue.&nbsp; Example, SCOUT has an attribute called "Range". Let's say it is set to 0/30 (Current/Max.) How can I get TokenMod to pull from there and set the Aura 1_radius? I see something similar for bars with code like this: --set aura 1_radius|@{move} but this doesn't work for radius. Thank you!
1600635662
Try this: !token-mod --set aura1_radius|@{selected|range} !token-mod --set aura1_radius|@{selected|range|max} When you use an @ the first portion after the { is the identifier for which token/character is being referenced. So you could use {selected or {target or a character id or a name, then a pipe followed by the attribute you are referencing and a second pipe for if you want to reference the max attribute.
1600638911
The Aaron
Forum Champion
API Scripter
You can also attach units if you'd like: !token-mod --set aura1_radius|@{selected|range}ft
Hello Aaron, I just switched over to your TokenMod, and I've been trying to make a macro that helps with creating npc tokens. But whenever I use it, they won't input the hp_max in line 1 &amp; 2. !token-mod {{ --set bar1_value|@{selected|hp_max} --set bar1_max|@{selected|hp_max} --set bar2_link|ac --set bar3_link|passive_wisdom --set name|@{selected|npc_name}-%%NUMBERED%% --on showname --off showplayers_bar1 --off showplayers_bar2 --off showplayers_aura1 --off showplayers_aura2 --set defaulttoken }} I can get it to work with the following code, but I have to manually input the hp value of the NPC into the attributes. --set bar1_value|@{selected|hp} --set bar1_max|@{selected|hp} Thank you for an amazing mod, and hope you can help me
1600684539
GiGs
Pro
Sheet Author
API Scripter
To get the max of an attribute with an attribute call you use @{selected|hp|max} Replace that underscore with a vertical pipe (|).
GiGs said: To get the max of an attribute with an attribute call you use @{selected|hp|max} Replace that underscore with a vertical pipe (|). Thank you so much
1600689987
Mads L. said: Hello Aaron, I just switched over to your TokenMod, and I've been trying to make a macro that helps with creating npc tokens. But whenever I use it, they won't input the hp_max in line 1 &amp; 2. !token-mod {{ --set bar1_value|@{selected|hp_max} --set bar1_max|@{selected|hp_max} --set bar2_link|ac --set bar3_link|passive_wisdom --set name|@{selected|npc_name}-%%NUMBERED%% --on showname --off showplayers_bar1 --off showplayers_bar2 --off showplayers_aura1 --off showplayers_aura2 --set defaulttoken }} I can get it to work with the following code, but I have to manually input the hp value of the NPC into the attributes. --set bar1_value|@{selected|hp} --set bar1_max|@{selected|hp} Thank you for an amazing mod, and hope you can help me You can even use the hp formula to set the hp randomly. Here setting bar1 with random hp and bar2 with AC: !token-mod --set bar1|[[@{selected|npc_hpformula}]] bar2_value|@{selected|npc_ac} Unfortunately it doesn't work with more than one selected tokens. The roll is performed only once and then set to all selected. But for one token it works.
I've tried searching the post about this, but I've found no answer to my upcoming question, as far as I've seen. If there has been, sorry for being completely illiterate...&nbsp; First off, I love the API so much, as it helps with so much. I do have one "problem" however: I use StatusMarkers I've gotten from the store, and setting them up is not a porblem, they work perfectly. But when I wabt to add macros to add different status markers, I need to look up their name in the "--help" section. I love the fact that you've added a section in there for available markers, but is there a command spesifically for listing available statusmarkers as the huge wall of text is kind of "in the way" if I want to do several at once? Again, sorry if this has already been answered somewhere, but I couldn't find it anywhere.
1600799494

Edited 1600799510
The Aaron
Forum Champion
API Scripter
Ah, there isn't yet.&nbsp; What I do is bring up the "Help: TokenMod" handout and pop it out or put it over the map while I edit and test macros.
1600802277

Edited 1600802296
Joe
Pro
Aaron, putting the help into a handout has made it much more convenient to reference, thank you again for doing that! Fred, if you open the status icons menu manually and hover over an icon, it should display the name of that status marker, if that is helpful to you.
The Aaron said: Ah, there isn't yet.&nbsp; What I do is bring up the "Help: TokenMod" handout and pop it out or put it over the map while I edit and test macros. I will try this then, thanks so much! =) Joe &nbsp;said: Fred, if you open the status icons menu manually and hover over an icon, it should display the name of that status marker, if that is helpful to you. I tried this when I first used the API, but the names of the icons aren't the ones I need to use, sadly. But thanks for the tip =)
1600806807
Fred said: I've tried searching the post about this, but I've found no answer to my upcoming question, as far as I've seen. If there has been, sorry for being completely illiterate...&nbsp; First off, I love the API so much, as it helps with so much. I do have one "problem" however: I use StatusMarkers I've gotten from the store, and setting them up is not a porblem, they work perfectly. But when I wabt to add macros to add different status markers, I need to look up their name in the "--help" section. I love the fact that you've added a section in there for available markers, but is there a command spesifically for listing available statusmarkers as the huge wall of text is kind of "in the way" if I want to do several at once? Again, sorry if this has already been answered somewhere, but I couldn't find it anywhere. If you add the set it appears on the right on your game's page (where you can launch the game and access the game's settings): e.g. There you can view the set via the dots menu. And then you see the set with the names of all statusmarkers. You can even change the name as you see fit.
1600812417
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Joe said: Aaron, putting the help into a handout has made it much more convenient to reference, thank you again for doing that! A related trick is to open the handout in the external view available from your campaign home page. That can be bookmarked and referenced from anywhere, in-game or out.
1600824316
Snow
Pro
I am using this macro to apply Bless markers to the tokens that have bless on them. !token-mod {{ --set statusmarkers|!angel-outfit --ids @{target|First Blessed|token_id} @{target|Second Blessed|token_id} @{target|Third Blessed|token_id} }} What I would like to also do is have the macro also apply the concentration marker to just the caster if that can be done.
1600828388
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
You could just add a second token-mod command to the macro.
1600828472
The Aaron
Forum Champion
API Scripter
Snow said: I am using this macro to apply Bless markers to the tokens that have bless on them. !token-mod {{ --set statusmarkers|!angel-outfit --ids @{target|First Blessed|token_id} @{target|Second Blessed|token_id} @{target|Third Blessed|token_id} }} What I would like to also do is have the macro also apply the concentration marker to just the caster if that can be done. You can do this with two commands in the same macro/ability: !token-mod {{ --set statusmarkers|!angel-outfit --ids @{target|First Blessed|token_id} @{target|Second Blessed|token_id} @{target|Third Blessed|token_id} }} !token-mod {{ --set statusmarkers|concentration --ids @{selected|token_id} }} This will work because the msg.selected is empty when @{target|...} is used, but the @{selected|...} will still yield a value.&nbsp; Switch "concentration" for whatever you use for a marker.
1600831906
Snow
Pro
Thanks
1601032726
I'm having a hard time figuring out how to turn on an aura with tokenmod is this not possible?
1601034772
The Aaron
Forum Champion
API Scripter
You need to set it's radius at a minimum, and likely want to set it's color: !token-mod --set aura1_radius|25ft aura1_color|rgb(0.5,0.25,1.0)
1601036083
Thank you very much!&nbsp; I was wracking my brain trying to guess that key name.&nbsp;&nbsp;
1601041175
The Aaron
Forum Champion
API Scripter
Yeah, I've been pondering a different way to organize the help. Right now it's by value type (so aura radius is in the section on "NumberOrBlank", and aura color is on the section "Color"), but that's a very programmer mindset way of doing it and destroys locality of reference for things like aura and lighting and images. I'm probably going to redo it to have a section on value types, then an index of related systems like Light, Aura, Permissions, etc.&nbsp;
1601546726
Joe
Pro
Hi Aaron, I'd like to use the name of a token to indicate a height for flying characters. &nbsp;My thought was to do something like this: !token-mod --set name|"Bob [?{Height in feet|0} ft]" --on showname But it doesn't seem to be working for some reason. I also tried adding to the name with syntax like the following (as a test): !token-mod --set name|+" (flying!)" But string concatenation doesn't seem to be a thing for either Roll20 or TokenMod. Can you please tell me if what I want is possible? &nbsp;My current fly macro uses the angel wings status marker, but having two of those on the token plus any other statuses tends to make it very hard to see the token's picture! &nbsp;:-) Ideally it would also turn showname on only if the input value is not zero, and turn it off if the input value is zero. &nbsp;However, I'm not sure how to do that either, and can always have a separate macro to turn off flight if needed. Thanks as always for your amazing scripts and your assistance!
1601554307
Joe said: Hi Aaron, I'd like to use the name of a token to indicate a height for flying characters. &nbsp;My thought was to do something like this: !token-mod --set name|"Bob [?{Height in feet|0} ft]" --on showname But it doesn't seem to be working for some reason. I also tried adding to the name with syntax like the following (as a test): !token-mod --set name|+" (flying!)" Hi Joe, I think it is the plus sign and in the first approach the "[]" which causes trouble. I am using this and it works fine: Macro "Fly": !token-mod --set name|"(^?{height} ft.)" --on showname --on showplayers_name --set statusmarkers|!fluffy-wing Macro "Fly-Not": !token-mod --set name|"@{selected|character_name}" --off showname --off showplayers_name --set statusmarkers|!fluffy-wing I guess, the "[" have to be escaped with \ maybe, but I didn't try.
1601557913
The Aaron
Forum Champion
API Scripter
I'm not sure why your macro wouldn't be working, it worked fine for me when I just tried it.&nbsp; What other scripts do you have running?&nbsp; It's possible there is one that is overwriting the name.
1601570382
Joe
Pro
The Aaron said: I'm not sure why your macro wouldn't be working, it worked fine for me when I just tried it.&nbsp; What other scripts do you have running?&nbsp; It's possible there is one that is overwriting the name. Very strange, because I tried Bernd's macros and they worked just fine (thank you!). &nbsp;So it can't be one of my other API scripts (mostly yours, Aaron :D) that is causing the problem. *shrug* &nbsp;Oh well, I'm good for now, thanks again!
1601570619
Joe
Pro
The Aaron said: I'm not sure why your macro wouldn't be working, it worked fine for me when I just tried it.&nbsp; What other scripts do you have running?&nbsp; It's possible there is one that is overwriting the name. One other possibility that occurred to me that I don’t have time to test right now: maybe different fancy quotes are throwing it off? &nbsp;The one that worked I copied directly from here, but normally my quotes go in curly by default. I did try to get straight quotes and still had the same issue, but I forgot to try single quotes, etc. &nbsp;Does your script handle all types of quotation marks (curly or otherwise)? No judgement if it doesn't, of course, and kind of weird that it hasn’t come up for me before now, but I’m not sure I’ve done that much with text in TokenMod.
1601572288

Edited 1601572371
GiGs
Pro
Sheet Author
API Scripter
Curly quotes (more properly called Smart Quotes, I believe) are very likely to be the problem.&nbsp; If you are using an editor that changes quotes to curly, it's best to stop using that editor for code work. Even if TokenMod handles them (or is updated to handle them) it will cause problems with other scripts sooner or later.
1601573209
Joe
Pro
GiGs said: Curly quotes (more properly called Smart Quotes, I believe) are very likely to be the problem.&nbsp; If you are using an editor that changes quotes to curly, it's best to stop using that editor for code work. Even if TokenMod handles them (or is updated to handle them) it will cause problems with other scripts sooner or later. That is definitely good advice in general, and I’ll certainly try to keep this lesson in mind, but I think you’re overestimating the time and professionalism I have to invest in macro writing; my “editor” is just Google Chrome where I play Roll20, and half the time during prep that’s on an iPad to boot. :D
1601574313
GiGs
Pro
Sheet Author
API Scripter
Joe said: GiGs said: Curly quotes (more properly called Smart Quotes, I believe) are very likely to be the problem.&nbsp; If you are using an editor that changes quotes to curly, it's best to stop using that editor for code work. Even if TokenMod handles them (or is updated to handle them) it will cause problems with other scripts sooner or later. That is definitely good advice in general, and I’ll certainly try to keep this lesson in mind, but I think you’re overestimating the time and professionalism I have to invest in macro writing; my “editor” is just Google Chrome where I play Roll20, and half the time during prep that’s on an iPad to boot. :D Hehe, understandable. For a long time my editor was Notepad++ (not the same as Notepad), and I got good results just by copying anything meant for code into notepad++ first, then copying it from there and pasting it into roll20 or wherever. That cleans up a lot of stuff that 'smart' editors add.
1601575257
The Aaron
Forum Champion
API Scripter
Yeah, utf-8 quotes would definitely screw it up.&nbsp; It only matches " and ' (good 'ole fashion ASCII) for strings.
1601593383
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
GiGs said: Curly quotes (more properly called Smart Quotes, I believe) are very likely to be the problem.&nbsp; I call them Typographer's Quotes, but I've been doing Pre-Press and graphic arts since before it was digital.
1603257871
I'm having difficulty with setting Updated Lighting properties. I can set has_bright, emits_bright, bright_distance, and emits_low just fine - but running into a small problem with low_distance. If I give it a set number, [ low_distance|20 ] this works fine. But if I try to use [ low_distance|+20 ] it will only work if that is the only option set. The following should work, I think. But it doesn't. !token-mod --set emits_bright|yes bright_distance|+10 emits_low|yes low_distance|+10
1603260036
The Aaron
Forum Champion
API Scripter
Hmm. I'll have to look at that. If you run that command, do you see no change? If so, what happens if you move the token?
1603292359

Edited 1603292385
The Bright Light distance updates to the +10, but the Low Light distance remains the same. If Low Light was 0 - it will add the +10, but if it's already a distance, it will not change - but the Bright Light will. Moving has no observable effect on the light distance.
Hello, I'm having an issue with setting up a torch. I have looked around, but I admit I got a bit lost in all the updates. Anyway: !token-mod {{ &nbsp; --on&nbsp; &nbsp; &nbsp; has_bright_light_vision &nbsp; &nbsp; emits_bright_light &nbsp; &nbsp; emits_low_light &nbsp; --set&nbsp; &nbsp; &nbsp; bright_light_distance|20 &nbsp; &nbsp; low_light_distance|20 }} As you can see both bright and low light starts from the token, but if I go into the token settings all is correct and if I apply the changes from there then it works properly. Probably somewhere there is a fix to it, or I am missing something.
1603378504
The Aaron
Forum Champion
API Scripter
That's bug in the Roll20 API's interface to UDL, outside the control of TokenMod. =(
1603382413

Edited 1603382440
StJohn70 said: !token-mod --set emits_bright|yes bright_distance|+10 emits_low|yes low_distance|+10 I've done some troubleshooting and here are my results: Using a +/- number on the low_light_distance does not work - only if the bright_light_distance is also being set with a +/-. Does not work: !token-mod --set emits_bright|yes bright_distance|+10 emits_low|yes low_distance|+10 doing two separate commands within one macro does not work, nor does calling another macro within the first (e.g. having one macro set the bright_distance, then calling another macro to set the low_distance) Works (but is not a solution for what I wanted): !token-mod --set emits_bright|yes bright_distance|10 emits_low|yes low_distance|+10 or only setting the low_distance by itself I took a look at the script file, but I'm not familiar with the api structures yet enough to tell where the error is. It doesn't look like a math error, so it may be an api issue.
1603383057

Edited 1603383093
The Aaron
Forum Champion
API Scripter
Ah, that's great info!&nbsp; Some background: The interface to UDL sets bright radius and dim radius as separate numbers, which differs from how LDL set light radius and dim start radius.&nbsp; I chose to mimic the behavior of the interface to make things less confusing.&nbsp; However, behind the scenes, the data on the token is still stored as total radius and dim start radius, so I have to do a conversion on the inputs.&nbsp; I've likely got a bug where it assumes there is a bright radius, so this will make it easy for me to focus investigation in that code.&nbsp; Thanks for the clear and detailed investigation, that will seriously help!
Hi I am finidng my scripts update the token details in regards to the UDL but not all the features trigger until I click the cog on the token and save changes then it works. Is there a way to tie that into the end of a macro script to make it work. I know UDL is fiddly at the moment but hoping you can help. Thanks
1603384978
The Aaron
Forum Champion
API Scripter
This is an issue on Roll20's side and not something that can be fixed by the API scripts.&nbsp; I'll ping the devs again about it.
Thanks, I even tried adding 2 lots of flipv in at the end to try and force that save but no joy. I'll keep an eye on this forum for changes
1603394166

Edited 1603394334
The Aaron said: You need to set it's radius at a minimum, and likely want to set it's color: !token-mod --set aura1_radius|25ft aura1_color|rgb(0.5,0.25,1.0) Hello, I'm trying to set a multi-option scrolldown menu with this. I'm kinda new to it obviously and I'm a bit lost, I have to replace the " | " with # otherwise the menu will be messed up, but if I do the colors don't apply. Any idea how I could fix it? This is what I currently have: !token-mod --set ?{AoE|6m Radius, aura1_radius#6m aura1_color#rgb(0.5,0.25,0.5)|9m Radius, aura1_radius#9m aura1_color#rgb(0.5,0.25,0.5)} (Sorry I don't know how to format it properly on the forums)
1603397842
The Aaron
Forum Champion
API Scripter
It's probably because of the commas in the color.&nbsp; Use HTML notation instead: !token-mod --set ?{AoE|6m Radius, aura1_radius#6m aura1_color#804080|9m Radius, aura1_radius#9m aura1_color#804080}
1603398837
Yup, that works perfectly, thank you!