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
This post has been closed. You can still view previous posts, but you can't post any new replies.

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

Yes, it still crashes as the sole one enabled. Your 0.000001 bandaid works.
1454780667
The Aaron
Pro
API Scripter
Weird!  Wanna PM me an invite and GM me to take a look?
sent
I seem to be having a bit of trouble with this script as well. For me, whenever I try to bring up the help menu (!token-mod --help), it crashes the API for me. I've just updated to the most recent version of the script, and have tried it with just the TokenMod script enabled, as well as just the TokenMod and IsGM scripts. Still, it crashes when I try to bring up the help menu. The rest of the commands seem to work still, just not the help. 
1454854117
The Aaron
Pro
API Scripter
Hmm.. it's an epidemic!  Hopefully I'll get to the bottom of this today.
1454856122
The Aaron
Pro
API Scripter
Update v0.8.18 -- Fixed crash bug on --help from recent changes to sendChat(). (Thanks RMcD & andrew M. ) It looks like when Riley pushed over that new sendChat() to support @{repeating_something_$1_attribute}, it caused the parser to start having issues with things in the format @{foo}, which exist in several examples within the help for TokenMod.  I've fixed it to not be an issue, but it's likely to show up in other scripts, so definitely let me know if you see it!
1454858853
The Aaron
Pro
API Scripter
Riley pushed out a change so this won't crash the API anymore (yeah!) and I checked all my other scripts and it shouldn't be an error.  You should still update to the latest version to get the correct text in the help, but it shouldn't crash now.  =D
Is there a way to show the original roll roll20 got? In the version of your script I'm using, it simply rolls internally and gives me the final count of damage. I'd love to see the dice roll still on the screen.
1456315958
The Aaron
Pro
API Scripter
Not currently, but I have some of that code written and will be adding it at a later date. 
Awesome! I can't wait- I've got some passive abilities in my homebrew system that activate if you roll a crit, so seeing the dice will be a huge help in that area.
I've been trying to use your token mod in some query-based macros- this | symbol causes me some trouble. It reads the use of that as a break in the query, so I can't use status markers as the result of a query. Any tips?
1456364938
The Aaron
Pro
API Scripter
You  can use # as an alternative to | in commands. This makes some macros easier to write. !token-mod --set ?{Feature|Dead, statusmarkers#dead|Red 3, statusmarkers#red:3}
Works like a charm- thanks!
1456408305
The Aaron
Pro
API Scripter
=D  
1456954785

Edited 1456955059
vÍnce
Pro
Sheet Author
Me again.  Sorry if i missed the function... but can Tokenmod change the name of a token(s)?  I would like to highlight a group of token's(maybe I'm going to spawn multiples of varying NPC/monster types...) and add %%NUMBERED%% to them for some reason... ;-P  Might also be a nice feature to change a token(s) name depending on a condition or whatever...
1456963840
The Aaron
Pro
API Scripter
Change name, yes.  Change name to something specific to the selected token, not currently.  I would be pretty easy to support concatenation or embedding similar to: !token-mod --set name|+" %%NUMBERED%%" !token-mod --set name|"${name} (color: %{aura1_color})" Hmm. I'll think on that. 
1457003121

Edited 1457003403
Ziechael
Forum Champion
Sheet Author
API Scripter
A work around, but won't work for multiple selections at once as far as my testing goes would be to run the following command: !token-mod --set name|"@{selected| character_name } %%NUMBERED%%" (replace the bold with whatever your sheets name field is called) Not elegant but a macro click per token isn't a bad thing i reckon? Sadly multiple selected tokens will all adopt the name of the token considered to be the 'primary' selected token :(
1457011946
The Aaron
Pro
API Scripter
Yeah, that's pretty much what I do: &nbsp; <a href="https://app.roll20.net/forum/permalink/3046527/" rel="nofollow">https://app.roll20.net/forum/permalink/3046527/</a>
1457013866
Ziechael
Forum Champion
Sheet Author
API Scripter
Darn it, thought i'd finally gotten something before you... must... try... harder...
One of my players is having an issue. The damage applier macro I have is working just peachy, but for some reason, she, and only she, cannot apply CERTAIN markers to any tokens in her control when using a certain macro. There are several macro nests, which I'll list here. #DragonsBreath Dragonsbreath links to /me casts Dragon's Breath on @{target|token_name}, dealing damage to 2 adjacent targets. !alter @{target|token_id} e -1d6+10 #2round 2Round links to !token-mod --set statusmarkers|interdiction:3 --ids @{selected|token_id} Before you ask, the 'dealing damage to 2 adjacent targets' is a cosmetic post, it doesn't actually mean anything to the macro, which is still single-target. Now, here's the wierd thing. I had her test out the #2Round macro, and it works fine, applies the interdiction markers just like it should, but #Dragonsbreath does not. If push comes to shove, I can just copy the !tokenmod command into her CHARACTER SHEET macro instead of the ability macro and see if that fixes it, but it's clearly a problem on her end- We tested extensively. Two other players did not suffer the same issue, but she does- again, only for certain markers. She is running Chrome on a Mac, both up to date and with a cleared cache. Any ideas?
1457245596

Edited 1457245612
The Aaron
Pro
API Scripter
If you remove the /em from the macro, does it work fine for her? &nbsp;(well, more specifically, the @{target})
I'll check tomorrow and let you know.
It still does not work, even if I remove the emote from it.
I also tried copying !token-mod --set statusmarkers|interdiction:3 --ids @{selected|token_id} Directly onto the ability listed on her character sheet, instead of nesting it through macros, to see if that would fix anything. It didn't.
1457310256
The Aaron
Pro
API Scripter
Hmm. This only happens for her? &nbsp;When you run it it works fine? &nbsp;If you PM me a join link and GM me, I can jump in and try to debug it.&nbsp;
Is it possible to use TokenMod to do something like the following (for a heal spell), to allow a heal spell to update a token value without exceeding the max value? !token-mod {{ &nbsp; &nbsp;--set &nbsp; &nbsp; &nbsp; bar1_value|[[{bar1_value+[[2d8]], bar1_max}kl1 ]] &nbsp; &nbsp;--ids &nbsp; &nbsp; &nbsp; @{target|1|token_id} }}
Yes, this should be possible: !token-mod {{ &nbsp; &nbsp;--set bar1_value|[[ {@{target|1|bar1} + [[2d8]], @{target|1|bar1|max}}kl1 ]] &nbsp; &nbsp;--ids @{target|1|token_id} }}
Thanks, I had my syntax wrong and was using bar1_max instead of bar1|max for the value.
Hey TheAaron! Oh mighty scriptomancer, whose API programmings are verily like unto magic itself, I beseech thee, grant me this boon or praytell that it cannot be granted at all, shy of the purposeful employment of a Ring of Wishes? Yeah... I wonder if you can make this (or any other) script flip the token's side? What I mean is, if the target is made of a rollable table token (ie: has many sides), can the script either choose a side, or pick one at random? I make extensive use of rollable tables for most of my mooks, and this would be a great way to speed up the placement process. Maybe it's already in there but I just missed it? Thanks! -Phnord
1459989770
The Aaron
Pro
API Scripter
I would love to do that. &nbsp;There is a small problem though. =( Since the API can't set any marketplace image urls into tokens, it can't change the side for them either. =( &nbsp;Riley tried to explain that to me once, but I don't think I completely followed why that was (If the image is already there, couldn't I just change the index?). &nbsp; Anyway, I hate making features that only work sometimes and seem to be inexplicably broken at others. &nbsp;I can probably add that and just loudly proclaim the issue when there is a marketplace image present....&nbsp; I'll see about doing that as soon as I finish this total rewrite of 50% of all my scripts... (and that unicorn...).
I know of this, Phnord: <a href="https://app.roll20.net/forum/post/2778056/script-token-face-change-based-on-rotation" rel="nofollow">https://app.roll20.net/forum/post/2778056/script-token-face-change-based-on-rotation</a>
*Gasp!* My faith is shattered! Could it be true, is TheAaron only 99% omnipotent?! I kind of understand that explanation, although it certainly seems like the kind of thing that could be done. Too bad, but nothing that we can't deal with. Silvyre: Wow,&nbsp;that's really close to what I'm looking for, although having to re-rotate the token after every change kind of defeats the purpose! This line looks interesting to me, TheAaron... it looks like it just flips the token over? And that doesn't work with marketplace assets in the tables for some reason? if (rot == 90) { tok.set("imgsrc", sides[1]); }; //Right Drat. Oh well, thanks for the 8,000,005 other things this script can do! -Phnord the terribly disappointed.
1459993465
The Aaron
Pro
API Scripter
In his case, the script works because all of his assets are stored in his user library. &nbsp;In the general case, assets might be in the user library or in the MarketPlace. &nbsp;The API is restricted from setting the imgsrc (URL) to any asset that is not in a user library (there's actually an interesting piracy implication in that...). &nbsp;When you use the API to set the side of a multisided token, it implicitly sets the imgsrc to the URL stored in the sides property at that index. If that URL happens to be in the MarketPlace, it simply fails to set it (and prints a message to the API Log). &nbsp;Hopefully that's clearer. Riley has said that setting MarketPlace assets in the API is coming (at GenCon last year), and when that happens, there is a whole world of things that can be done. &nbsp;All of Stephen S.'s mapping scripts will be 100% usable out of the box with none of the download/upload/set urls steps. &nbsp;I have several scripts ready to go that will make use of that feature...
Phnord: Another script option that I've used (with, to The Aaron's point, non-Marketplace assets in my library) is here:&nbsp; [Script] change token image from rolltable
The Aaron said: &nbsp;I have several scripts ready to go that will make use of that feature... I am in no way surprised to hear this! Looking forward to it. Lady Victoria said: Phnord: Another script option that I've used (with, to The Aaron's point, non-Marketplace assets in my library) is here:&nbsp; [Script] change token image from rolltable Yeah, these scripts would work perfectly... except that I already have So. Much. STUFF. premade, and I really do not want to start over. Again. Plus, a lot of them use marketplace stuff, so. Oh well. Thanks for the help folks! -Phnord
Hi, I added the script with the new One-Clic Install. I enabled the option "players can use --ids" from this interface, and it throws this error: TypeError: Cannot set property 'playersCanUse_ids' of undefined
1460077505
The Aaron
Pro
API Scripter
Hmmm... I'll take a look!
1460078209
The Aaron
Pro
API Scripter
Ok. Silly typo. &nbsp;I pushed a patch:&nbsp; <a href="https://github.com/shdwjk/Roll20API/blob/master/To" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/To</a>...
Great, thanks!
Is there a way to use a selected token's bar values to influence a target token's bar values? For instance, right now I use: !token-mod --set bar3|-3 --ids @{target|token_id} As a basic little attack macro for this wargame I'm working on for some friends, so when you use this, you click on an enemy unit and it subtracts 3 from the target's HP. &nbsp;What would be REALLY swell is if I could use one of the bars as an "attack stat", so I wouldn't have to set up a specific macro for each unit type's different stats (having one for -3, one for -2, etc.). &nbsp;Is this even possible? I'm super new to scripts so my apologies if this is really obvious and I'm just not seeing it. Thanks!
1460149875
The Aaron
Pro
API Scripter
Something like: !token-mod --ignore-selected --set bar3|-@{selected|bar2} --ids @{target|token_id} Should work.
The Aaron said: Something like: !token-mod --ignore-selected --set bar3|-@{selected|bar2} --ids @{target|token_id} Should work. Fantastic, exactly what I wanted. &nbsp;Thank you!
I'm feeling really dumb right now. How would I make the example work if I wanted to subtract the selected unit's bar1 (attack) from the target unit's bar2 (defense), and then subtract the resulting value from the target unit's bar3 (HP)? Basically, how can I (or can I even) evaluate an expression?
1460153415
The Aaron
Pro
API Scripter
Like this? !token-mod {{ --ignore-selected --set bar2_value|-@{selected|bar1} bar3_value|-[[@{target|bar2}-@{selected|bar1}]] --ids @{target|token_id} }} Note, for TokenMod, bar1_value and bar1_max are the two sides of the bar1 stat. &nbsp;bar1 is a pseudo stat that is equivalent to adjusting both stats. /em sets their token's hitpoints (bar1_value and bar1_max) !token-mod --set bar1|[[3d6]] Also, you might need to care for the value below zero: !token-mod {{ --ignore-selected --set bar2_value|[[ { @{target|X|bar2}-@{selected|bar1}, 0 }kh1 ]] bar3_value|[[ { @{target|X|bar3}-(@{target|bar2}-@{selected|bar1}) , 0}kh1 ]] --ids @{target|X|token_id} }}
Is it possible yet for a player to trigger this in a macro and have it alter the selected tokens bars and stuff or is it still gm only?&nbsp; Is it possible to use this with another api script in the same macro? I have the following using powercard script and then at the end would like to add a tokenmod call that subtracts the stamina cost from the token, and adds the aura statusmarker with the number 4. This is the macro, the powercards part does its part but it seems the tokenmod part is not doing its part. this macro is supposed to be triggered by the player btw. Can you tell me why it won't work? !power {{ --name|@{selected|Name} --leftsub|@{MW1-WepName} --rightsub|@{MW1-SkillName} --Attack Roll + Skill:|[[ [$Roll|NH] 1d100cf&gt;96cs&lt;5 + @{selected|MW1-Skill}]] --?? $Roll.base &lt;= 5 ?? **Fumble Roll** Fumble or Miss| --?? $Roll.base &gt;= 96 ?? **Critical Roll** Critical or Normal hit| --Damage|[[ @{MW1-Damage}]] VS @{target|Name} }} !token-mod --ids @{selected|token_id} --set bar2_value|-@{selected|MW1-BSC} statusmarkers|aura:4
1460636570
The Aaron
Pro
API Scripter
TokenMod has always worked for selected tokens for players, but there is a setting for the GM to allow players to specify token ids with the --ids argument. &nbsp;Turning that setting on will allow what you have written to work, provided the attributes are correct. Sometimes the API's message.selected gets fouled up by the use of @{target}. &nbsp;You might try removing the --ids argument and running the command alone just to make sure everything is working as expected, then try reintroducing it to the full macro. &nbsp;Also, you can use the same multi-line form with TokenMod: !token-mod {{ --set bar2_value|-@{selected|MW1-BSC} statusmarkers|aura:4 --ids @{selected|token_id} }} Let me know if that clears it up.
Thanks that worked great. I guess the whole token ID thing was over my head. So basically the --ids command allows the selected token to trigger the script even if its not run by the gm?
1460676357

Edited 1460676441
The Aaron
Pro
API Scripter
--ids lets you specify a list of tokens to apply changes to. &nbsp;Example: !token-mod {{ --set statusmarkers|!angel-outfit --ids @{target|First Blessed|token_id} @{target|Second Blessed|token_id} @{target|Third Blessed|token_id} }} This toggles the Angel Wings status marker on/off for up to 3 tokens. &nbsp;(Duplicates are removed, so you can triple click a single token to only affect one). &nbsp;This is useful for a cleric casting bless. &nbsp;Similarly: !token-mod {{ --set statusmarkers|!archery-target --ids @{target|Toggle Hunter's Mark|token_id} }} Will let a ranger mark the target of their Hunter's Mark. In both cases, the player wouldn't have control of the targets (so couldn't select them) and must specify the token ids with --ids. &nbsp;By default, that option is Off because a malicious player might change the hit points of a monster or troll other players by changing their token names. &nbsp;I wanted it to be a conscious decision on the part of the GM to allow those capabilities. You can toggle the player availability of --ids in the help at the very bottom, or execute this command: !token-mod --config players-can-ids to toggle it directly.
So token id's change everytime you change maps? How do I get the token id's so that I could substitute them into a static macro. The above macro gives everyone a debuff when they attack due to being off balance. Now what I am looking for is a GM macro that passes time and reduces the aura count on all my players or any other status effects I have going on. !token-mod {{ --set statusmarkers|!aura:-1 --ids "token ID string of numbers and letters here"|token_id} "token ID string of numbers and letters here"|token_id} "token ID string of numbers and letters here"|token_id} }} Where each of the token id's corresponds to a token in use by my players. When I travel to a new page I would need a way to get the new token id's to substitute into the macro. is there a way I can see those id's? Sorry for being such a noob I have never worked with token id's before, just character names.
1460692206

Edited 1460692399
The Aaron
Pro
API Scripter
You would most likely need to have a couple of macros which just ask you to target so many tokens, or operate on the selected tokens. &nbsp;When using target on more than one token, you need to use a distinct label. &nbsp;@{target| &lt;label&gt; |&lt;attribute&gt;} WRONG : &nbsp;This will prompt once for a token and supply the same ID 3 times. !token-mod {{ --set statusmarkers|?aura:-1 --ids @{target|token_id} @{target|token_id} @{target|token_id} }} WRONG : &nbsp;This will be the same as above, aside from using the prompt "pick" in the target selection. !token-mod {{ --set statusmarkers|?aura:-1 --ids @{target|pick|token_id} @{target|pick|token_id} @{target|pick|token_id} }} RIGHT : &nbsp;This will prompt 3 times and supply 3 different token ids (provided you clicked 3 different tokens). !token-mod {{ --set statusmarkers|?aura:-1 --ids @{target|pick 1|token_id} @{target|pick 2|token_id} @{target|pick 3|token_id} }} Using the selected tokens is probably much easier for your use case: !token-mod {{ --set statusmarkers|?aura:-1 }} This will decrement the number on the aura status marker, if it exists, and remove it when it reaches 0. &nbsp;Note the use of ?aura instead of !aura . &nbsp;! toggles the status marker on and off. &nbsp;? toggles it off if it is at zero. Just to fully answer your question, you could get the raw token id for a graphic like this: /w gm Token ID is @{target|token_id} which would spit out something like -J1awas12adsf and could then be used with: !token-mod {{ --set statusmarkers|?aura:-1 --ids -J1awas12adsf }} but as you mentioned, each individual token is unique and has it's own id so this is really only useful for setting up one time effects on a specific map. &nbsp;(Hide a graphic, tint a secret door, etc) &nbsp;Using --ids with @{target} is really where it is most useful.