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.

The Aaron said: Not if you're using @{selected} or setting represents.  @{selected} can't resolve to more than one token.  You can almost get there by using HP and Armor_Value instead, it will assume they are on the represented character.  There isn't a way to fix the name though.  I could probably add something to support API side resolution of some pseudo @{selected} element, but that doesn't exist right now. Just so I'm clear and understand this properly. I posted something about this a long while ago here . But I've noticed you can now use TokenMod to effect multiple tokens at once. There also appears to be in the code something for inline rolls. I'm assuming (and just want to clarify), we still can't feed TokenMod inline rolls based off from attributes on individual token's characters, is that correct? I ask, because I've recently forked a copy TokenAction to support Traits and Reactions, now I'm wondering if I should start experimenting and make my own thing that also sets up my tokens with random HP like I mentioned in the previous post. I'm trying to use existing scripts as much as possible though as javascript still somehow confuses me compared to c# and .net libraries with the luxury of Visual Studio's intellisense to find what I need when I'm not sure.
1532532007
The Aaron
Pro
API Scripter
You are correct, there is no syntax to interpret inline rolls and {@selected} references on a per token basis.  The reason for this is primarily that those things get resolved before sending to the API (Try taking the ! off the front and you'll get a rough approximation of what the API sees for it's message). I've mentioned the possibility of a syntax to resolve these on the API side.  It would probably need to look something like: !token-mod --set name|"@^{selected|character_name}" bar1_value|[^[@^{selected|hpdice]^] Honestly, I've done most of the work for this already in the OnMyTurn script's resolver, I should probably just go ahead and add it.  I'm taking suggestions for syntax. =D  Probably need it for: Inline rolls.  Considering [^[ ]^] instead of [[ ]] Attribute references: @^{ } instead of @{ } Might be able to do executing abilities as well: %^{ } instead of %{ } Anything I've missed?
Thanks for the clarification. I'm going to try and incorporate the bits I need from TokenMod into a script I've cannibalized from TokenAction to try and get this. As for suggestions for syntax, ChatSetAttr uses the slash as you may have saw in the comments from Jakob in my other post yesterday. It worked well enough, but I also don't know the ramifications that might have on your script.
1532534108
The Aaron
Pro
API Scripter
Ah, that's a great point!  I should entmoot with Jakob about that.
For syntax?  Maybe something like !token-mod --set <has_multiple|@{selected|id1/name1}> <has_multiple|@{selected|id2/name2}>... Could !token-mod check for the names of selected objects first then return a 1 for <has_multiple>, indicating to perform the actions on multiple targets?  Would that be too clunky? For inlines, I think the ^ is already used in 5e[Shaped] as a Capitalization mark on a template, don't know if that would cause a conflict...
1532553923
The Aaron
Pro
API Scripter
I think I'll just make the assumption that if you force the evaluation onto the API side, it gets applied on a per token basis.  I might add a flag to tell it NOT to do that, but I think API side evaluation implying per token is the sensible default.
Sorry, if I'm butting in, it's just part of my process in trying to learn :/
1532555544
The Aaron
Pro
API Scripter
No complaints here! =D  Definitely join the conversation!
Hey, I'm making macros so that i don't have to open my character Sheet (I have a Dream).  I would love to be able to query the currently set Token-Status, to apply different status affects in macros... i.e.: I have a Barb, i'd like to flag him with a Red Status to indicate he is raging.  Then when i make an attack, i would like to use that stsatus (0/1 or True/False) to add the +2 Damage or Advantage to Strength Saves. This same idea can be applied to things like bless, or blindness...I would be using PowerCards to resolve attacks and Token-Mods to query/set Token Status'. Thanks in advance.
This script looks amazing. I hope you can forgive some really entry-level questions, but I've always been a Hardware kind of guy and script makes my eyes gloss over. I'm in a game where we use multi-sided tokens to represent various poses our characters have and I'd like to know if the following are possible and how to actually go about doing them. What limited knowledge of coding and macros makes me think these can be done, I just don't know how to actually make it work in practice on roll20. 1: A simple button that appears when you click your token that lets you toggle your horizontal back and forth.  We use full-view sprite-style images that have explicit left or right facing and only the GM can toggle our horizontal.  2. The same but with setting yourself to back or front. We have a lot of issues of people standing over each other when we're moving around. 3. The complicated one. We all have a full suite of sprite poses, would there be any way to group select us all and hit a single button to turn us all into a pre-selected state? For example, when combat kicks in would there be any way to have us all go to State 2 (or whatever the term for a rollable token is) simultaneously, which is our Combat sprite? Sub-question-  any way to make a button that you push and it pops up a message only you can see into the chat that has your various states laid out as named buttons you can push without spamming the other players with messages? That sounds really complicated when I type it like that but I hope you can get what I'm going for. Push macro button, chat message sends to you alone with your options, push one of those and it sets your state.  Thank you for your help. I'm not very good when it comes to coding and I can understand what most of these things do  just now how to actually accomplish them in-game. 
1534173698
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The answer to all your questions is "Yes". Token mod can do all those things. The syntax is  !token-mod --set currentside|### Where ### is the side number you wish to display. Naturally, as you suggest, you will need to be methodical in ordering your sides. However, for your horizontal flipping, there's another script which may interest you: psIsoFacing  is able to flip horizontally based on the last direction moved. It doesn't change faces so far as I can tell, so it may not play nicely with rollable table side-changing. But if you are good with javascript, you may be able to find a way to pick elements from each script.
1534176496
The Aaron
Pro
API Scripter
Just to follow up, to push a token (or selected tokens) backwards, you can use: !token-mod --order back Additionally, with your menu, you might find you like using one of: !token-mod --set currentside|2 --ids @{My Character Name|character_id} The above will find all tokens representing your character and change them all in one go.  That can be nice as you don't have to select your token to run it (but be aware that it will change every token on every page that represents that character)
1534176693
The Aaron
Pro
API Scripter
RyGuy said: Hey, I'm making macros so that i don't have to open my character Sheet (I have a Dream).&nbsp; I would love to be able to query the currently set Token-Status, to apply different status affects in macros... i.e.: I have a Barb, i'd like to flag him with a Red Status to indicate he is raging.&nbsp; Then when i make an attack, i would like to use that stsatus (0/1 or True/False) to add the +2 Damage or Advantage to Strength Saves. This same idea can be applied to things like bless, or blindness...I would be using PowerCards to resolve attacks and Token-Mods to query/set Token Status'. Thanks in advance. Take a look at this Script:&nbsp;<a href="https://app.roll20.net/forum/post/6613608/slug%7D" rel="nofollow">https://app.roll20.net/forum/post/6613608/slug%7D</a>
The Aaron said: RyGuy said: Hey, I'm making macros so that i don't have to open my character Sheet (I have a Dream).&nbsp; I would love to be able to query the currently set Token-Status, to apply different status affects in macros... i.e.: I have a Barb, i'd like to flag him with a Red Status to indicate he is raging.&nbsp; Then when i make an attack, i would like to use that stsatus (0/1 or True/False) to add the +2 Damage or Advantage to Strength Saves. This same idea can be applied to things like bless, or blindness...I would be using PowerCards to resolve attacks and Token-Mods to query/set Token Status'. Thanks in advance. Take a look at this Script:&nbsp; <a href="https://app.roll20.net/forum/post/6613608/slug%7D" rel="nofollow">https://app.roll20.net/forum/post/6613608/slug%7D</a> @The Aaron, that looks like it’s perfect! &nbsp;I’ll try it out tonight or tomorrow. &nbsp;This script basically just turns the status markers into token attributes? &nbsp;Just inline calls for their values? &nbsp;I’m floored that this wasn’t the initial implementation or at least built into the basic API. thank you for the quick response.
lol - already referencing it Aaron? &nbsp;hehe
1534247382
The Aaron
Pro
API Scripter
Yup! &nbsp;One thing to be aware of is you’ll likely need to set them with a 1 on them.&nbsp;
The Aaron said: Yup! &nbsp;One thing to be aware of is you’ll likely need to set them with a 1 on them.&nbsp; From what i read about querying these values: !token-mod --set statusmarkers|blue This&nbsp; should return True/False if active/Inactive !token-mod --set statusmarkers|blue:&lt;0-9&gt; This should return the numeric value the status marker is set to. Is that correct?
1534281734
The Aaron
Pro
API Scripter
In the case of that script I have above, you'd need a positive number to have something to multiply by.&nbsp; I could likely set it up so that 0 and 1 are both treated as a 1 for the above script, which would allow you to have it "on" and "off" without needing to have it "on at 1" and "off or 0".
1534309820
Mik Holmes
Pro
Marketplace Creator
Hey Aaron, big fan of your work! I've got a question (which may have been answered above with regards to multiple selected tokens: this won't work), but this situation feels like there's gotta be a deceptively easy solution that I'm just not seeing. I'm trying to use TokenMod and rollable tables to quickly change token's names from a list of adjectives. Eg, I have a table called Wolf-Adjectives (containing entries like "Snarling," "Scar-Eyed," etc) and want to be able to select a group of wolf tokens and run: !token-mod --set name|"[[1t[Wolf-Adjectives]]] Wolf" For a single token it works great, but selecting multiple tokens will only roll on the table once and give everyone the same name. While I could select each token individually and run the macro for each, I would use this a lot in my games if I could figure it out. This could be a limitation of rollable tables themselves, of course.&nbsp; Thanks for any help you can give, and (from what I've seen skimming the forums), helping people with R20 stuff for half a decade!
1534336325
The Aaron
Pro
API Scripter
It's not currently possible to set unique results with TokenMod.&nbsp; The reason is that the inline roll ( [[1t[Wolf-Adjectives]]] in your example) is expanded on the client side before it gets sent to the API.&nbsp; The API will just see: !token-mod --set name|"$[[1]] Wolf" And some meta data on the message containing "Snarling". To fix this, I'll have to rewrite the command parser to take something like [^[1t[Wolf-Adjectives]]^] and do the expansion for each individual token on the API side.&nbsp; I've not had the opportunity to do this yet.
1534367390
Mik Holmes
Pro
Marketplace Creator
Thanks anyway! That's what I thought, though I had hoped I was missing something with the functionality of macros. It would be nice to have a "for each selected" option in macros by default.
The Aaron said: In the case of that script I have above, you'd need a positive number to have something to multiply by.&nbsp; I could likely set it up so that 0 and 1 are both treated as a 1 for the above script, which would allow you to have it "on" and "off" without needing to have it "on at 1" and "off or 0". I tested my theory and whether the marker is active or not, if there isn’t a 1+, it returns 0. &nbsp;In my case, “inactive = 0” and “active w/o any numerical value = 1” and “active w/ any numerical value = the associated numerical value” would be perfect.
1534393056
The Aaron
Pro
API Scripter
I think I can get you that feature, RyGuy.&nbsp;
1534393694

Edited 1534398538
Sorry to post so many questions, but i couldn't find this answer in either scripts pages... How do i use this script from within a PowerCard?&nbsp; I have tried "--!token-mod ..." and "--hroll|!token-mod ..." but it just&nbsp; treats it like a hidden tagname and prints out all the other "--" commands.&nbsp; I also tried replacing the additional "--"'s with "_"'s, but that wasn't any different.&nbsp; It's being treated like a string, not a command... This PowerCard: !power {{ --corners|0 --tokenid|@{selected|token_id} --emote|~L@{selected|token_name} flies into a rage~L --name|Rage --leftsub|+2 Melee Damage --rightsub|Advantage on Str Checks --hroll|!token-mod --ids @{selected|token_id} --set statusmarkers|+red:1 }} Returns: After further searching, i found the answer on the PowerCards page: --api_ - This special tag starts with “--api_” followed by the command to call an API script. The content of the tag is passed to the API script after replacing underscores (_) with two dashes (--). Example: --api_token-mod|_ids @{selected|token_id} _ignore-selected _set statusmarkers|blue This example calls the TokenMod API script to set the “blue dot” status marker for the selected token. --api_token-mod|_ids @{selected|token_id} _set statusmarkers|+red:1
1534423129
The Aaron
Pro
API Scripter
Great!&nbsp; If that doesn't work, be sure to let me know.
1534439825
Kai
Sheet Author
First. Great script, a must have. Your work is appreciated, The Aaron. Second. Is there a way to set the avatar image of a character with tokenmod, as simple as the token image is set? Something like --set avatarimage, perhaps? Perhaps with an option to set the avatarimage to the default token image? Thanks in advance.
1534440871
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That would be (very) nice! But I don't think that the interface is touchable by the API.
1534445384
The Aaron
Pro
API Scripter
Actually, it it is available for the API: avatar "" URL to an image used for the character. See the note about avatar and imgsrc restrictions below. It isn't available on TokenMod as TokenMod has traditionally only manipulated tokens (with very limited forays into Character for setting the Default Token and setting ControlledBy).&nbsp; I could likely add this, or at least provide a standalone that would let you do it.
1534447261
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Ah, I thought we were talking about the "avatar" that appears on the tabletop above your character name. Roll20 uses that word for both that and the portrait in the journal. The tabletop one would be nice to be able to change automatically.
1534447419
The Aaron
Pro
API Scripter
Oh yeah, agree!
1534783995
Kai
Sheet Author
The Aaron said: &nbsp;I could likely add this, or at least provide a standalone that would let you do it. One of both options would be great (and yes, I was talking about the portrait in the journal).
Reaching back a page, a thought occurs that might be a step towards making the auto-trigger rage-power script more vanilla... Wolf Thunderspirit said: Ugg ... though I'm sure there is no other way than IDs to do specific actions though, is there? &nbsp;Something more vanilla? &nbsp;If I put the macro lines in the rage description box somehow, that would cover the usage ticking and be able to omit the 3rd line. &nbsp;if the player clicks their rage, it decrements use and fires the code to turn it on. &nbsp;But that won't tick the modifier to increase damage, so I still need to use an ID for that. Then also, to turn it off, I need a macro with identifiers. What I was kinda looking for is if anyone in my group wants to play a barbarian, "Here's your macros, set one in the rage box, make your own macro for the other." &nbsp;But this is more my level of work - in finding their ID's for them to be able to do both as their own token macros. Not vanilla.&nbsp; Very chocolate.&nbsp; Thought we had what I was looking for for a moment, and we do, it's just a lot of extra and individualized work.&nbsp; Maybe I'll get lucky and no one will roll a barbarian .... lmao. keithcurtis said: Unfortunately, the only option to make it more vanilla is to ensure that all characters have their Rage mod and Rage class feature in the same order, so that you can refer to them by sequence number instead of discreet ID. Granted that my idea still necessitates finding out what the discreet IDs of any given character's rage powers are (or other powers that something of this general form could be applied to), but would it be possible to achieve a middle ground by coding the script to query for its own unique attribute (like '_rage_power_discreet_ID_value'), that could then be used as a statically-coded pointer/feeder for the actual activation script, which would reference that static value on each character sheet to determine what value for he discreet ID to plop into the triggering macro that Keith wrote? (Probably not in a macro, but perhaps in a fairly simple API script that can be invoked via macro?) Edited to add: As an additional step, would it be even remotely possible to construct a setup wrapper API script that could be set to listen for the next triggered ability that possesses a discreet ID, ask what it was for, and create the necessary additional character attributes based on the answer to make the pointer-referencing idea above work without needing to do anything more fiddly or onerous than make the character dance for you (as it were)?
1537066364
The Aaron
Pro
API Scripter
It would probably be easier and more useful to write a script that monitors the creation/editing of abilities and looks for something like: repeating_action_[_action_name=Rage]_action_data and the looks for the repeating_row_&lt;ID&gt;_action_name attribute with a value of “Rage”, and then rewrites the ability to use the same Row ID.&nbsp;
I knew there had to be a way to make it a less bespoke process... Would, in theory, such a script be able to have another section that would riffle through various repeating actions already extant on a character to do the same thing? Also, unrelated to the Rage-widget, I'm hoping to be able to find some advice... I'd like to create a macro or API script that lets me, as the GM and with a set of tokens selected, pass a provisional health adjustment value for possible application to each token in the set, and execute the following steps for each token: check the token's linked character for records or information that indicates some kind of ability to mitigate or augment health adjustments, and present a summary of all health-adjustment-related information found on the linked character for the GM to use to adjudicate how the health-adjustment should be modified for that token and while prompting the GM for an adjustment value for the token (by name) apply the adjustment (default 0) to the initial value apply the resulting value to the health record for the token. In the event that the token is not linked to a character sheet and has a null-value for the bar-max, the widget should do nothing, but if the token either isn't linked to a character or (1) came up empty, I'd want the default adjustment of zero to be automatically applied as the results of (2) (no prompt needed) and (3) applied directly... I do not think that I can accomplish this with only the features available in token-mod, and I suspect that the complexity of what I'd like to display (or not display, depending) will necessitate an API script rather than a macro (especially if it's going to be system-agnostic), but either way, I know that the final step of applying the actual health adjustment is something that token-mod is eminently capable of doing, if that's something that can be done in an API script?&nbsp; I'm still pretty new at this, so any suggestions you can provide would be much appreciated.
1537099872

Edited 1537121368
The Aaron
Pro
API Scripter
That’s definitely the domain of an API script. TokenMod can make adjustments, but for the prompting you’d need another script. If you need to pre-check values and make adjustments, that would be entirely a new script. If you want to enforce constraints (not below zero, not over max, etc) you could do that with a script that observes the changes on the token as well as the changes made by TokenMod (I posted one that handles temporary hit points that way last week).&nbsp;
The Aaron said: That’s definitely the domain of an API script. TokenMod can make adjustments, but firvtge promoting you’d need another script. If you need to pre-check values and make adjustments, that would be entirely a new script. If you want to enforce constraints (not below zero, not over max, etc) you could do that with a script that observes the changes on the token as well as the changes made by TokenMod (I posted one that handles temporary hit points that way last week).&nbsp; I saw the temp-HP script, that's part of what inspired me, as well as the rage power macro (the contributions from Keith in particular). I have to ask, "firvtge promoting"? Is that shorthand jargon that I'm too new to grok, or just a typo?&nbsp;
1537121269

Edited 1537121403
The Aaron
Pro
API Scripter
Hahaha! &nbsp;That’s me typing in my phone before I’m fully awake and without proof reading. =D I edited my original post. :)
Cool beans. That's what I suspected, thanks for confirming.&nbsp; (On both counts.)
Is there a way to flip an aura radius? For example, something like this that would either set the raidus to 2 if it's unset, or unset it if it's already set. !token-mod --set aura1_radius|!2
1537883390
The Aaron
Pro
API Scripter
Try it with a ? Instead of a ! And see if that works. If not, I can probably add it.&nbsp;
The Aaron said: Try it with a ? Instead of a ! And see if that works. If not, I can probably add it.&nbsp; ?2 only removes the radius.
1537920218
The Aaron
Pro
API Scripter
Hmm... try your original command: !token-mod --set aura1_radius|!2 with this version:&nbsp;&nbsp; <a href="https://gist.github.com/shdwjk/0ce43d4df51c6db38593b30cba4e59a0" rel="nofollow">https://gist.github.com/shdwjk/0ce43d4df51c6db38593b30cba4e59a0</a>
1537920847

Edited 1537921027
Lex
Pro
The Aaron said: Hmm... try your original command: !token-mod --set aura1_radius|!2 with this version:&nbsp;&nbsp; <a href="https://gist.github.com/shdwjk/0ce43d4df51c6db38593b30cba4e59a0" rel="nofollow">https://gist.github.com/shdwjk/0ce43d4df51c6db38593b30cba4e59a0</a> Works great! Thanks! I am using a Token Action to toggle a Disadvantage Aura: !token-mod --set showplayers_aura1#on aura1_radius#!1 aura1_color#ff0000
1537921263
The Aaron
Pro
API Scripter
Cool.&nbsp; I'll update the docs and run that out then!&nbsp; Not sure how useful it will be, but just because of the nature of how the properties are processed, this will work on light_radius, light_dimradius, light_multiplier, and adv_fow_view_distance, in addition to aura1_radius and aura2_radius.
1537921952
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Some players have auras they use over and over (ex. Paladins). It's better than separate on-off macros.
1537922475
The Aaron
Pro
API Scripter
Update v0.8.41 &nbsp;-- Added ! for toggling Number or Blank fields (Thanks&nbsp; Lex ): !token-mod --set aura1_radius|!20
1538496550

Edited 1538496573
I see a lot of people using this API to manage conditions in DnD 5e but only for adding status indicators to the token. Can this API also write in chat? For example, I add a condition to a token, the API will display the condition info in the chat to my players when I apply it but also when it's the token turn in the turnorder. Can this API do that ?
1538497618
Victor B.
Pro
Sheet Author
API Scripter
You want combat tracker, status info and token mod.&nbsp; They all work together to get what you want.&nbsp;&nbsp;
Victor B. said: You want combat tracker, status info and token mod.&nbsp; They all work together to get what you want.&nbsp;&nbsp; I'm wondering, instead of combat tracker, if there was a way to get turnmarker to reveal conditions on the character from statusinfo when its the character's turn.&nbsp; Of course - hmmmm :/ - guess i'm in the wrong forum thread for that ...