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.

1623117780

Edited 1623154713
timmaugh
Pro
API Scripter
The air, still just a moment before, stirs, swirling the trash littering the truck stop parking lot. Electricity arcs between parked semi trailers, climbing like the elder dead who feel the bonds of their graves weakening. A hole forms in the air, expanding outward and slicing through the trailers, through the pavement, a laser scalpel through flesh. Sphere and electricity vanish. The air hangs. A massive figure rises from the steaming blacktop. I find myself needing your clothes, your boots, and your motorcycle for some reason. B^| Hey, JP... Aaron gave you the explanation of why the call doesn't work -- that it's a matter of timing. By using a meta script, you can get the value of that repeating field after Roll20 updates the attribute on the sheet but before token-mod gets involved to set the bar's value. You can get the repeating field with a Fetch construction (Fetch is a meta-script that's available in the one-click). I'm not sure what system you're playing (to know what the sub-attributes are), but let's assume that items in the repeating list "classfeature" have a sub-attribute named "featurename" that holds the name of the list item as it would appear on your character sheet. Let's also assume that the name of the list item you want to work with (the list item represented by the row ID -lgkxvjxvyxnubmbhux5) is named "T800 Luck". The "uses" sub-attribute is 30 before you activate your ability, and 25 after. In that case, your Fetch construction would look like: *(Gromgar Three-Scars.classfeature.[featurename="T800 Luck"].uses) So the full token-mod call would be: !token-mod --set bar3_value|=*(Gromgar Three-Scars.classfeature.[featurename="T800 Luck"].uses) ( Scripts Required : Fetch) (Fetch will run with or without ZeroFrame , and in this case you won't need ZF... but ZF does enhance the overall effect of all of the meta-scripts as you start to need to do more with them. ZeroFrame is also in the one-click.) EDIT: fixed minor typo in my code, above.
Thanks so much for the help Aaron and timmaugh - you two are amazing. I am using the 5e shaped sheet and my final call was: !token-mod --set bar3_value|=*(Gromgar Three-Scars.classfeature.[name="Lay on Hands"].uses)
1623187319

Edited 1623187402
Hi Aaron, great that v0.8.69 is out! Thanks a lot. I just tried what I was dearly missing: the defaulttoken option. And now the bar style and location is kept! Thanks a lot Bernd
1623187612
The Aaron
Roll20 Production Team
API Scripter
No problem!  It's a brave new token bar world!
1623434617

Edited 1623436163
Thanks as always to @The Aaron for his great work on Token Mod. And for his great work on Bump. I've recently converted to UDL... so far, so good... but I am running into one issue. I've got a simple Bump macro set for my characters who can turn invisible so that they can bump and unbump themselves at will. I've got Bump configured to Auto Push, Slave and Unslave, so the macro is nothing more than "!bump" ... easy. Worked fine under LDL, no issues. Now with UDL, I've also got these tokens configured for UDL night vision at 60', using the nocturnal effect. When the players bump themselves, or when I bump them, the night vision effect resets to "none." This leads to some very weird stuff happening... strange circles of darkness around other tokens... I'm gonna presume that's a possible UDL bug issue that will get worked out one day, but in the meantime, even if that stuff weren't happening, I'd want my bumped characters to still experience the nocturnal effect. I tried to get around this by adding: !token-mod --set night_vision_effect|nocturnal to the bump macro, but it doesn't prevent the "effect = none" issue on bump. The nocturnal effect is restored, however, on unbump. Any idea how to figure this out? Currently I'm manually adjusting each time they bump, but with a Cloak of Shadows monk who is visible/invisible depending on whether or not someone lights a torch nearby, it's gonna get tedious. Thanks in advance for the assistance!
1623446875
The Aaron
Roll20 Production Team
API Scripter
Ah!  UDL support for bump is on my todo list. I'll see if I can't knock that out tonight, it's just a matter of adding the right properties to the duplication lists. 
1623471204
The Aaron
Roll20 Production Team
API Scripter
Lol!!
1623548350
The Aaron
Roll20 Production Team
API Scripter
The Aaron said: Ah!  UDL support for bump is on my todo list. I'll see if I can't knock that out tonight, it's just a matter of adding the right properties to the duplication lists.  Ran into a bug with UDL and created objects that's preventing me from getting an updated Bump out...
Bummer. Is it something you think is gonna take a while for Roll20 to sort out before you can work your magic?
1623691383
The Aaron
Roll20 Production Team
API Scripter
I think they'll sort it out in a reasonable amount of time.  I might be able to find a way to force it to update by doing a change after a create, but I'm still testing that.
Does tokenmod support custom icon sets?  I have a game I play in where token mod is available, but the DM has installed their own status icons and I can't seem to get them to set when I try. !token-mod --set  statusmarkers|bleeding-out
1623776192
The Aaron
Roll20 Production Team
API Scripter
Definitely.  Look at the help for a list of all the ones it knows about: !token-mod --help It will look something like this, but your list will be different.: You can use the name, like "diamond" in the image above, but if there is a space in the name, you'll need to use the tag, like "Eye_Balls::2591986" in the above.
1623776246
The Aaron
Roll20 Production Team
API Scripter
In your picture, it looks like "Bleeding Out" is two words, so you'll need something like "Bleeding_Out::1351534134".
1623776871
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Interesting. Does the name matter then, or just the number? Would "AAARGH_It_Hurts::1351534134" work?
1623777153
The Aaron
Roll20 Production Team
API Scripter
No, the name definitely matters right now, though it is unique, so I suppose I could adjust it to accept just the number.  I'm not sure there's much benefit to it though as having just that number in your macros/abilities would make it kind of hard to tell what it's doing. What I should really do is support quoting the name like "Bleeding Out", or possibly have some fallback search methods like if you ask for "Bleeding-Out" and I don't find it, look for a version with spaces or underscores there.  I'll look into that.
Hi Aaron, one question concerning the bar style. I have a game where currently all tokens are bar style compact and want to make them standard with the hp numbers (-> text overlay) visible to editors. This is what happens by default when I switch from 'compact' to 'standard' using the UI. If I set 'compact_bar|off' the bar gets bigger, but the text_overlay is set to 'Hidden': Couldn't find to set this via token-mod. Is it not exposed to API (yet)? Or is it possible to set the text overlay by default to 'Visible to Editors' as it is on the UI? Thanks! Bernd
1623975223

Edited 1623975695
Night Vision Effect Night Vision Effect specifes how the region of night vision around a token looks. There are two effects that can be turned on:  dimming  and  nocturnal . You can disable Night Vision Effects using  off ,  none , or leave the field blank. Any other value is ignored. Available Night Vision Effect Properties: night_vision_effect Enable the nocturnal Night Vision Effect on a token: !token-mod --set night_vision_effect|nocturnal Enable the dimming Night Vision Effect on a token: !token-mod --set night_vision_effect|dimming Disable any Night Vision Effects on a token: !token-mod --set night_vision_effect|off !token-mod --set night_vision_effect|none !token-mod --set night_vision_effect| I'm trying to modify my Tokens Nightvision rightnow and it works so far as intended. The only thing I can't find anything about is whether there is an porperty to affect the Night Vision effect starting range, specifically the dimming range, since I prefer my Tokens to have dimming start of 0, but the default value seems to be 5 for the macro. And If I don't misunderstand, I can't add an value to the effect, to indicate the start value, as in: !token-mod --set night_vision_effect|dimming 0 wouldn't be possible, right? Edit: Formatting
1623981136
The Aaron
Roll20 Production Team
API Scripter
Bernd: Text Overlay is not exposed yet. Lars: There isn't a setting for the radius at which to start the timing effect.
1623986027

Edited 1623986096
Thanks for the answer! I've been awake for way too long and I'm not quite sure if you're saying that there isn't a setting in general, or in TokenMod, I was reffering to the "Dimming Start"   But I guess there isn't a setting for it in TokenMod eitherway, so I'll just get used to it anyways. Another question that I've stumbled upon... I've made a macro for adding and subtracting Vision and lights to a token. Adding light work perfectly, but when I'm adding or taking away vision the Tokens Vision doesn't correctly update. Only after going into the Tokn Setting and saving will the vision correctly display (eventhough the settings were already altered).I'm also using 'defaulttoken', since I'd also like to use the macro to create new tokens, and end up with tokens that can't see anything eventhough their settings say that they have brightvision and nightvision. That's what the token sees, after dragging it from the journal into the map, here's the brightvision in contrast I've seen a post of Zalirae (about a year ago) where they build a rolling query, which I used for heavy inspiration, since I don't really code. there was a problem that I also face, in which a blind macro takes away all vision, but the token is still able to see everything in it's brightvision. You've answered that UDL would need to have API access to the viewing angles. If I didn't misread that feature is implemented into TokenMod by now. It seems to me more like it's a problem with the token not correctly updating, is there a resolution for that problem I couldn't find? just for refference, here's the code I've been using, the light sources have been cut out, since they don't seem to cause any problems and update instantly: !token-mod {{ ?{Vision|Brightvision, --set has_bright_light_vision#on has_night_vision#off defaulttoken |Nightvision, --set has_bright_light_vision#on has_night_vision#on night_vision_distance#30 night_vision_effect#dimming night_vision_tint##0c343d defaulttoken |Blind, --set has_bright_light_vision#off has_night_vision#off defaulttoken } }} The credit pretty much goes to Nick Olivo for the single macros themselves and Zalirae for the template for rolling Queries. Thanks a lot for answering to all these questions, I really appreciate it. Sorry if I came across a bit too meticulous in the beginnging, I just wasn't sure if there was bad phrasing on my part, causing a miscommunication, or if there was a misunderstanding on my part Edit: Typos
1623987729
The Aaron
Roll20 Production Team
API Scripter
Whoops!  Sorry about that.. in the middle of my Thursday night game and didn't notice the typo. That really should have said: There isn't a n API setting for the radius at which to start the d im m ing effect.
The Aaron said: Whoops!  Sorry about that.. in the middle of my Thursday night game and didn't notice the typo. That really should have said: There isn't a n API setting for the radius at which to start the d im m ing effect. No worries. Thanks for the clarification. Enjoy your game!
The Aaron said: Bernd: Text Overlay is not exposed yet. Pity. But thanks!
I just wanted to pop in and say thank you.  I recently started using your script for a west march style campaign.  Being able to set a token to our default setup with a single click has saved so much time.  Not to mention easy vision control and wildshape/polymorph changes
1624203042
The Aaron
Roll20 Production Team
API Scripter
Great!  Glad to hear you're finding it useful!
1624499855
Chad
Plus
Sheet Author
I would like to setup a macro to run a specific tokenmod on all tokens on a page that are NPCs, and a different tokenmod on all tokens on a page that are PCs. It basically sets up bars, vision, etc.... I imagine this can only be done via the API right or am I missing a way to do it with a macro?
Chad said: I would like to setup a macro to run a specific tokenmod on all tokens on a page that are NPCs, and a different tokenmod on all tokens on a page that are PCs. It basically sets up bars, vision, etc.... I imagine this can only be done via the API right or am I missing a way to do it with a macro? If you're going to use Token-Mod, you already have the API. I'm not aware of a selection choice in Token-Mod that allows you to select only PCs or only NPCs. If you also have ScriptCards installed, you should be able to use that to do what you're looking for: !script {{ --~|array;pagetokens;PageTokens;@{target|Any Token on the Page|token_id} --~tokenid|array;getfirst;PageTokens --:PCorNPC| --C[*[&tokenid]:npc]|1:>NPC;[&tokenid]|2:>PC;[&tokenid] --~tokenid|array;getnext;PageTokens --?[&tokenid] -ne ArrayError|PCorNPC --X| --:PC| --@token-mod|_ignoreselected _ids [%1%] <whatever you're doing to PCs> --<| --:NPC| --@token-mod|_ignoreselected _ids [%1%] <whatever you're doing to NPCs> --<| }}
1624506758

Edited 1624537336
timmaugh
Pro
API Scripter
Chad said: I would like to setup a macro to run a specific tokenmod on all tokens on a page that are NPCs, and a different tokenmod on all tokens on a page that are PCs. It basically sets up bars, vision, etc.... I imagine this can only be done via the API right or am I missing a way to do it with a macro? The  Meta Toolbox  might have something for you. A little  ZeroFrame , a little  SelectManager , a little  Fetch , a little  APILogic ... all to help you run TokenMod the way you want to. Assuming you have all of the tokens on a page selected, you could iterate a conditional statement over all of them: !forselected(^) token-mod {^& if @^(selected.npc_specific_attribute[not found]) != "not found"}...npc settings...{^& else}...pc settings{^&end} That would assume that you have only selected tokens that are either PC or NPC. If there are graphics on the page that you have chosen, you could filter them with one more branch of the IF statement. This time, since you'll have a branch of the logic that should do nothing with TokenMod (if you are iterating over a selected graphic instead of a PC or NPC), we'll bury the "token-mod" in the text that is only conditionally included: !forselected(^) {^& if @^(selected.npc_specific_attribute[not found]) != "not found"}token-mod ...npc settings...{^& elseif @^(selected.pc_specific_attribute[not found]) != "not found"}token-mod ...pc settings{^& else} {^&end} While you can virtually select tokens to iterate over, the ability to select all tokens on a given page is not yet available in the meta-toolbox. I'm trying to decide whether Fetch or SelectManager make the better home for that ability... or a completely different/new meta-script.
1624516058
Chad
Plus
Sheet Author
Colin C. said: Chad said: I would like to setup a macro to run a specific tokenmod on all tokens on a page that are NPCs, and a different tokenmod on all tokens on a page that are PCs. It basically sets up bars, vision, etc.... I imagine this can only be done via the API right or am I missing a way to do it with a macro? If you're going to use Token-Mod, you already have the API. I'm not aware of a selection choice in Token-Mod that allows you to select only PCs or only NPCs. If you also have ScriptCards installed, you should be able to use that to do what you're looking for: --@token-mod|_ignoreselected _ids [%1%] <whatever you're doing to PCs> Thanks for the suggestion. I spent a long time on it tonight and found our that the line above is cause for a problem. _ignoreselected doesn't work because tokenmod expects it to be ignore-selected. On the other hand, if I use ignore-selected the call from ScriptCards to TokenMod completely fails. (The - isn't allowed). I also tried _ignore_selected and that had no impact either. In all cases, the selected token received the impact of both routines, with the other token not changing. Still looking into it.
1624516120
Chad
Plus
Sheet Author
timmaugh said: A little  ZeroFrame , a little  SelectManager , a little  Fetch , a little  APILogic ... all to help you run TokenMod the way you want to. Thanks for the suggestion, I'll try this one tomorrow too. Thanks!
Try this line correction: --C[*[&tokenid]:npc]|1:>NPC;[&tokenid]|2:>PC;[&tokenid] The hyphen in "ignore-selected" shouldn't make any difference at all. ScriptCards only cares about double hyphens as tag lines. For the token-mod line, it should be "_ignore-selected" rather than just simply "ignore-selected" because Token-Mod requires the "--" construction before that argument, and ScriptCards will convert a leading "_" to "--" for API calls. Underscores inside or trailing a string have not impact on the conversion. Chad said: Colin C. said: Chad said: I would like to setup a macro to run a specific tokenmod on all tokens on a page that are NPCs, and a different tokenmod on all tokens on a page that are PCs. It basically sets up bars, vision, etc.... I imagine this can only be done via the API right or am I missing a way to do it with a macro? If you're going to use Token-Mod, you already have the API. I'm not aware of a selection choice in Token-Mod that allows you to select only PCs or only NPCs. If you also have ScriptCards installed, you should be able to use that to do what you're looking for: --@token-mod|_ignoreselected _ids [%1%] <whatever you're doing to PCs> Thanks for the suggestion. I spent a long time on it tonight and found our that the line above is cause for a problem. _ignoreselected doesn't work because tokenmod expects it to be ignore-selected. On the other hand, if I use ignore-selected the call from ScriptCards to TokenMod completely fails. (The - isn't allowed). I also tried _ignore_selected and that had no impact either. In all cases, the selected token received the impact of both routines, with the other token not changing. Still looking into it.
1624546773
Chad
Plus
Sheet Author
I got so frustrated with it I actually tested it line by line to track it down. I fixed some other little issues in the code and did more testing. I've confirmed that the hyphen matters. Looking through the ScriptCards forum thread, looks like he just did a re-write of the processing and there were some bugs, he's fixed them but I wonder if the one that auto-installs has updated yet. The actual conditional that works is: --C[*[&tokenid]:npc]|1:>NPC;[&tokenid]|0:>PC;[&tokenid] Oddly, ids is also being completely ignored, even though the id is being sent as expected... I checked with some debug outputting. I'm wondering if the format of the id sent to tokenmod is a little off somehow, though I don't see anything in my tests. Here is my full code, including the spammy output I am using to test. In this case I am not using ignore-selected (Adding that still causes nothing to happen), the selected token is hit by both subs and the other token is not touched at all. !script {{ --#bodyFontSize|11px --#whisper|gm --#debug|0 --~|array;pagetokens;PageTokens;@{selected|token_id} --~tokenid|array;getfirst;PageTokens --:PCorNPC| --C[*[&tokenid]:npc]|1:>NPC;[&tokenid]|0:>PC;[&tokenid] --~tokenid|array;getnext;PageTokens --?[&tokenid] -ne ArrayError|PCorNPC --X|End of Execution --:PC| --+PC|Setting [*[%1%]:character_name] as a PC ([%1%]) --@token-mod|_set rotation#180 _ids [%1%] _report gm|TestCheck-PC_[%1%] --<|3 --:NPC| --+NPC|Setting [*[%1%]:character_name] as a NPC ([%1%]) --@token-mod|_set rotation#180 _ids [%1%] _report gm|TestCheck-NPC_[%1%] --<| }} When I enter the command manually, it works as expected (Both the selected token and the token identified by ids rotate): !token-mod --set rotation#180 --ids -Mcv_4Ik3rPONtHmk3SKv --report gm|TestCheck-PC_-Mcv_4Ik3rPONtHmk3SKv So two issues: ignore-selected - The hyphen still causes the command to not run at all ids - ids seems to be ignored when called from scriptcards, even though the test output comes out as expected Colin C. said: Try this line correction: --C[*[&tokenid]:npc]|1:>NPC;[&tokenid]|2:>PC;[&tokenid] The hyphen in "ignore-selected" shouldn't make any difference at all. ScriptCards only cares about double hyphens as tag lines.
I believe the --ids argument needs to precede the settings.
1624559084
The Aaron
Roll20 Production Team
API Scripter
The order of --ids doesn't actually matter. I can't really speak to the !script stuff, I've never tried it out.
Quick token-mod question I created a simple script to update the vision and lighting..but it seems that the changing the "directional_bright_light_total" setting but it  does not take effect until I go in and save the settings on the token? So the change is made in the settings. Am I doing something wrong? I am using UDL to be clear maybe that is the issue? Here are the commands I am using...also the grid is set to 1 squares so 3 is the number of squares since running Savage Worlds. !token-mod --on emits_bright emits_low --set bright_distance#3 low_distance#3  directional_bright_light_total#25  !token-mod --on emits_bright emits_low --set bright_distance#3 low_distance#3  directional_bright_light_total#360  Also the the  directional_low_light_total setting do anything? 
Tokenmod can give control of a token to a certain character pretty easily, im wondering if there is a command to make it visible in that characters journal as well? 
1624829052
The Aaron
Roll20 Production Team
API Scripter
This is a current bug with the UDL API interface.  It's something I hope gets fixed soon.  You probably need to toggle has_directional_bright_light as well: !token-mod {{ --on emits_bright emits_low has_directional_bright_light --set bright_distance#3 low_distance#3 directional_bright_light_total#25 }} !token-mod {{ --on emits_bright emits_low --off has_directional_bright_light --set bright_distance#3 low_distance#3 directional_bright_light_total#360 }}
1624829156
The Aaron
Roll20 Production Team
API Scripter
Marowfreeze said: Tokenmod can give control of a token to a certain character pretty easily, im wondering if there is a command to make it visible in that characters journal as well?  There isn't, though that could be pretty easily handled with a script.  The only reason the character's controlled by is exposed on the token is because it is inherited by the token if the token represents a character.  Same thing for setting Default Token.
Greetings. Been using TokenMod for the first time...it's excellent :) Has anyone figured out a way to simulate light interfering with infravision/night vision? Maybe this is a question that should be in the UDL thread?
1624882966
The Aaron
Roll20 Production Team
API Scripter
That's probably best asked in its own new thread. You'll get more views by the community at large that way. 
I just noticed that if you change a token to represent a different sheet than it originally was, things on the sheet don't work. i.e. clicking bless as a global save mod or attack mod, no longer applies bless to saves or attacks.. if it was clicked, unlicking it does not remove it from the same. Equipping a shield does not add to AC, etc... Is this a known thing?  Any fix? (P.s.  I hate that you can't search threads on roll20 forums)
1624938662
The Aaron
Roll20 Production Team
API Scripter
When you say "a different sheet", you mean a different Character, yes?  What character sheet are you using?  Are you using a Character Sheet specific API Script? (which one?) What other scripts do you have installed?
The Aaron said: When you say "a different sheet", you mean a different Character, yes?  What character sheet are you using?  Are you using a Character Sheet specific API Script? (which one?) What other scripts do you have installed? I am using the 5e normal sheet.  What I am doing is a macro to control Wild Shape forms.  The only other script installed is ChatSetAttr, but is not used in this macro. Query asks what form, then --token-mod to set the currentside image, size, and represents the sheet for the chosen creature. the first option in the query returns it to the normal character token and represents the character sheet. It works fine just changing images and sizes, but as soon as "represents" goes to a different sheet, then is reverted to the original character sheet, is when the stuff stops working. I can send the actual macro, but would prefer to DM that if possible.
1624940325
The Aaron
Roll20 Production Team
API Scripter
Sure, PM/DM it over.
Sent.  Thank you
Craig T said I am using the 5e normal sheet.  What I am doing is a macro to control Wild Shape forms.  The only other script installed is ChatSetAttr, but is not used in this macro. Query asks what form, then --token-mod to set the currentside image, size, and represents the sheet for the chosen creature. the first option in the query returns it to the normal character token and represents the character sheet. It works fine just changing images and sizes, but as soon as "represents" goes to a different sheet, then is reverted to the original character sheet, is when the stuff stops working. I can send the actual macro, but would prefer to DM that if possible. For Wildshape you probably switch to a different sheet as well: that for the bear/wolf/spider/etc.? If you set the atk/save modifier on the PC sheet, this other sheet doesn't have this configuration. Maybe that's the problem?
Bernd S. said: For Wildshape you probably switch to a different sheet as well: that for the bear/wolf/spider/etc.? If you set the atk/save modifier on the PC sheet, this other sheet doesn't have this configuration. Maybe that's the problem? It's not just mods.  You can select them, but they don't apply to rolls.  It's also items.  Let's say the character has a shield, once you switch from the wildshape sheet back to the character sheet, un/equipping the shield no longer changes the AC.  It's that way for any item that alters the sheet.  Basically, anything that changes anything on the sheet no longer works.  Exiting/Reentering the game will fix it though.
Hey there! I think this is likely a case of me missing an extremely obvious step with some very basic arguments, but I'm running into a problem using tokenmod to reduce the dim light radius for my players. I've got macros set up to toggle a lantern on (bright 30 dim 30), but when they attempt to use another macro to reduce that dim radius to 5 it instead becomes 35. Similar issues are happening with other things - swapping from a lantern (30/30) to a torch (20/20) seems to be no problem, but swapping to any other light source where the dim light is lower than 20 creates a situation where the dim light increases by that number instead. Clearing the dim light to 0 or toggling it off first don't seem to do a single thing to fix this, and this was working a little while ago, so I'm stuck on ideas for troubleshooting.  Macros in question:  !token-mod {{ --set emits_bright|true --set bright_distance|30 --set emits_low|true --set low_distance|30 }} !token-mod {{ --set emits_bright|false --set emits_low|true --set low_distance|5 }}
Try using an equals sign: !token-mod {{ --set emits_bright|false --set emits_low|true --set low_distance|=5 }}