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.

1417888840

Edited 1417889084
Update: I seem to have found a cause/workaround. Removing the commas from the target list does the trick. It's possible something about the API has been updated to not require any commas in a target list. You may want to adjust your instructions to reflect this. The command works if re-written as follows: !token-mod --ids @{target|1|token_id} @{target|2|token_id} @{target|3|token_id} @{target|4|token_id} --set bar1_value|+[[?{Total XP? (will be split 4 ways)}/4]]
1417889534
The Aaron
Roll20 Production Team
API Scripter
Ah! Yeah, no commas. I don't explicitly state that and there are no examples showing more than one. I'll make it more clear in future versions. Thanks!!
1417889899
vÍnce
Pro
Sheet Author
The Aaron said: Ah! Yeah, no commas. I don't explicitly state that and there are no examples showing more than one. I'll make it more clear in future versions. Thanks!! It's because Aaron never pauses...why would he allow them in his scripts?
Anytime! The least I can do is help polish this script up. This saves me LOADS of time in my campaign. Me and the guys appreciate it very much.
1417890346

Edited 1417892221
The Aaron
Roll20 Production Team
API Scripter
John C. said: Anytime! The least I can do is help polish this script up. This saves me LOADS of time in my campaign. Me and the guys appreciate it very much That's exactly why I write them. :) Vince said: It's because Aaron never pauses...why would he allow them in his scripts? Ha!! Probably true... :)
1418229869
The Aaron
Roll20 Production Team
API Scripter
Update v0.53 -- You can now toggle status markers on and off by prefacing them with the ! symbol. This will add the Rook piece if it isn't there, but remove it if it is: !token-mod --set statusmarkers|!white-tower Adding with a number will set the number if the status was not present, so this would add blue with a value of 3 if it wasn't already there, but clear it if it was: !token-mod --set statusmarkers|!blue:3 Adding relative numbers is less useful since they would always be operating on 0 (if the status wasn't there) or not being applied (because the status is being removed if it was there already), but they don't cause an error. I also expanded the help to show --ids and how to use it for multiple token ids (Thanks John C.), as well as cleaning up a few other points.
Awesome! Thanks for the update =)
1418398057
The Aaron
Roll20 Production Team
API Scripter
Yeah... I was showing my macros for adding and removing a status marker to someone and though, why am I doing this in two macros when it could be a toggle for one? Used it in my game last night and cut my macro bar by half. =D
1418403112
vÍnce
Pro
Sheet Author
Aaron, can you implement mind-controlled toggling? You really need to take your scripts to the next level...
1418403678
The Aaron
Roll20 Production Team
API Scripter
=D I know you're joking, but if you happen to have an XWave headset or NeuroSky EEG Biosensor and some disposable income, I bet I could work something out... (...and technically, your mind is controlling your fingers, so it is mind-controlled toggling! =D )
1418970706

Edited 1418970756
would it be possible to use this command in a macro !token-mod --set bar3_value|-1 with caster targeted and then a macro to add the amount healed to bar one of a different token not the caster. say a healer using channel energy for instance so the first command subtracts 1 from bar 1 which is daily uses of channel and then have another command in the same macro then roll and add amount rolled to target tokens bar 1 health This is for a Pathfinder game
1418971251
The Aaron
Roll20 Production Team
API Scripter
Should be. For players, you'd need to turn on their ability to use --ids: !token-mod --config players-can-ids|on Then you could do a macro like this: !token-mod --set bar3_value|-1 /em uses Channel Energy on @{target|Target|token_name} !token-mod --set bar1_value |[[{@{target|Target| bar1 }+ 2d8+2 , @{target|Target| bar1 |Max}d1}kl1]] --ids @{target|Target|token_id} Assuming that the health is in bar1 and the spell heals 2d8+2. You might have to add --ids @{selected|token_id} to the first line if it doesn't seem to be working. @{target} causes tokens to be de-slected, which I believe occurs before the message is sent to the api: !token-mod --set bar3_value|-1 --ids @{selected|token_id} /em uses Channel Energy on @{target|Target|token_name} !token-mod --set bar1_value|[[{@{target|Target|bar1}+2d8+2, @{target|Target|bar1|Max}d1}kl1]] --ids @{target|Target|token_id}
Thanks im gonna test this out when im not as tired as heck. Just macroed about 100 spells ugh glad thats done
1421599064
Gen Kitty
Forum Champion
So how goes the companion script to this, editing character attributes from chat/macros? :>
1421599770
The Aaron
Pro
API Scripter
Life is starting to slow down enough I should be able to start working on it. :)
1422573541

Edited 1422573593
vÍnce
Pro
Sheet Author
So, I've had the tokenmod script installed forever and finally got around to including it in my arsenal of GM goodies. Can I a set bar value from an attribute that is auto-calculated? I was trying to pull AC from the PF sheet and it enters " (10 " for the bar value. This happens to match the first three digits of the formula used to calculate AC on the sheet.
1422576773
The Aaron
Pro
API Scripter
Should be able to put it in an inline roll: !token-mod --set bar1_value|[[@{selected|AC}]]
1422578059

Edited 1422578118
vÍnce
Pro
Sheet Author
The Aaron said: Should be able to put it in an inline roll: !token-mod --set bar1_value|[[@{selected|AC}]] Perfect. Thank you Sir. Next question(you knew this was coming...), what would prevent !token-mod from choosing the appropriate attribute from the list of available attributes? 2 of 3 bars are properly associated, but one of them has the correct value, but it still shows "None" for the associated attribute...? here's my macro !token-mod --set bar3_value|@{target|NPC-HP} bar3_max|@{target|NPC-HP} bar2_value|[[@{target|CMD}]] bar1_value|[[@{target|AC}]] --on showname --ids @{target|token_id} Bar2 has the right value, but is labeled "None" on the token.
1422581321
The Aaron
Pro
API Scripter
OOH! I think I misunderstood the original question. Are you talking about setting the represents for the bar? !token-mod --set bar1_link|NPC-HP bar2_link|CMD bar3_link|AC You have to set the represents first though, as those names are taken as attributes off the represented character.
1422598662
The Aaron
Pro
API Scripter
BTW, if you want bar1's current and max value set to the same thing, you can do this: !token-mod --set bar1|45 This will be expanded as if you put in bar1_value and bar1_max, with the added advantage that you can do it with an online roll and get the same number for both: !token-mod --set bar1|[[5d8+14]]
1422599134
vÍnce
Pro
Sheet Author
Thanks for your help Aaron. Here's my current macro !token-mod --set represents|@{target|character_name} bar3_value|[[@{target|NPC-HP}]] bar3_max|[[@{target|NPC-HP}]] bar2_value|[[@{target|CMD}]] bar1_value|[[@{target|AC}]] --on showname --ids @{target|token_id} This changes the token appropriately, however all three Bars are still labeled "None". Shouldn't they show the attribute they are associated with? I'm sure I'm missing something...
1422599259

Edited 1422599322
vÍnce
Pro
Sheet Author
The Aaron said: BTW, if you want bar1's current and max value set to the same thing, you can do this: !token-mod --set bar1|45 This will be expanded as if you put in bar1_value and bar1_max, with the added advantage that you can do it with an online roll and get the same number for both: !token-mod --set bar1|[[5d8+14]] Cool. I'll update my macro once I get it working... lol
1422600208

Edited 1422600793
The Aaron
Pro
API Scripter
It is a bit confusing and subtle. Let me break it down: This sets the value and max of bar3 to the value of the attribute NPC-HP of the target token (Phnord's Mook, "none" for represents, individual hp for each copy of the token): !token-mod --set represents|@{target|character_name} bar3_value|[[@{target|NPC-HP}]] bar3_max|[[@{target|NPC-HP}]] bar2_value|[[@{target|CMD}]] bar1_value|[[@{target|AC}]] --on showname --ids @{target|token_id} This links bar3 to the attribute named NPC-HP on the character the token represents (Phnord's Character, "NPC-HP" for represents, shared hp for all copies of token): !token-mod --set represents|@{target|character_name} bar3_link|NPC-HP bar2_value|[[@{target|CMD}]] bar1_value|[[@{target|AC}]] --on showname --ids @{target|token_id} Savvy? :)
1422602041
vÍnce
Pro
Sheet Author
Yes!!! link and value
1422606083

Edited 1422608083
vÍnce
Pro
Sheet Author
So I'm pretty sure I understand the difference between bar_link and bar_value and how they apply. I can link NPC-HP, but AC and CMD are auto-calculated and I can't seem to link to them... The attributes for AC and CMD show up as "linkable" items in the token properties if I want to manually select them. This macro should link the target's ac attribute to bar1, but it doesn't. !token-mod --set represents|@{target|character_name} bar1_link|ac --ids @{target|token_id}
1422625391
The Aaron
Pro
API Scripter
Vince said: So I'm pretty sure I understand the difference between bar_link and bar_value and how they apply. I can link NPC-HP, but AC and CMD are auto-calculated and I can't seem to link to them... The attributes for AC and CMD show up as "linkable" items in the token properties if I want to manually select them. This macro should link the target's ac attribute to bar1, but it doesn't. !token-mod --set represents|@{target|character_name} bar1_link|ac --ids @{target|token_id} Should it be: !token-mod --set represents|@{target|character_name} bar1_link|AC --ids @{target|token_id} I'm a stickler for case sensitivity...
I have never been able to successfully bar_link AC on the Pathfinder sheet, it just generates an error. In fact I think I have tried several times to bar_link any autocalculated fields and I am almost certain they always fail. The funny thing is if you choose them from the token settings it works fine.
1422631535
The Aaron
Pro
API Scripter
Interesting! I'll have to try that out...
1422640699

Edited 1422641088
vÍnce
Pro
Sheet Author
I tried changing the case as well. It's strange because it will show the attribute as AC on the sheet, but the token attribute selection has lowercase... Normally I use uppercase in my macros without issue. I just checked the " Complete list of Pathfinder Attributes " thinking that perhaps there is a mixed case of AC and CMD. Nope. One version, uppercase.
1422643435
The Aaron
Pro
API Scripter
Check your attributes on the character, do you have more than one AC?
1422647472

Edited 1422647507
vÍnce
Pro
Sheet Author
"attr_AC" shows up twice on the PF sheet. Since it's an auto-calculated field, it does not show up on the Attributes and Abilities tab. This is also the case for "attr_CMD".
1422648556
The Aaron
Pro
API Scripter
Hmm.. I wonder if it doesn't have an attribute object? That would certainly prevent the API from finding it. Try making an attribute with @{AC} in it and setting to that.
1422650214
vÍnce
Pro
Sheet Author
I manually added the attribute AC with a value of "50"(as a test) on the Attributes and Abilities tab and I can link to it using !token-mod --set represents|@{target|character_name} bar1_link|AC --ids @{target|token_id} I noticed the token properly links bar1 with the sheet's AC at that point, however the AC attribute I manually created still has "50" as the value and doesn't change with the sheet's value. If I delete the AC attribute I created, bar1 is no longer linked to AC. Maybe auto-calculated attributes need to manually be created first before tokenmod can link properly?
1422653696
The Aaron
Pro
API Scripter
hmmm.. I think I need to experiement...
1422654639
vÍnce
Pro
Sheet Author
NP Aaron. After I started this I realized I only need to change the bar values for my current use(import statblock, add macros, and token setup). Linking would be handy for conditions however. I have a much better understanding of your tokenmod script now and I'm sure I will be "sprinkling" my campaign with more of it.
1422655508
The Aaron
Pro
API Scripter
=D good to hear!
Aaron, I didn't see this in the help file. Is there a way to --set bar_link| to None? I tried blank and none and None, and none of those seem to do it. What I'm trying to do is set it None, and leave the values, so I can set npc_hp, switch it to none, in order for hp to not track across multiple tokens.
Try "" instead.
1424617413

Edited 1424617544
The Aaron
Pro
API Scripter
Nice catch, I completely omitted any reasonable way of accomplishing that. I've updated to allow clearing the link for a bar by specifying an empty Attribute Name: !token-mod --bar3_link| Thanks Ari K.! Update v0.7 -- Added support for unlinking bars by passing an empty Attribute Name. (Thanks Ari K.!) Git: <a href="https://github.com/shdwjk/Roll20API/blob/master/To" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/To</a>...
1424621322

Edited 1424621481
EepMoody
API Scripter
Ari K. said: What I'm trying to do is set it None, and leave the values, so I can set npc_hp, switch it to none, in order for hp to not track across multiple tokens. An easy way to do what you're describing in 5e if you put Hit Dice down on the NPC sheet is: !token-mod --set bar1|[[@{selected|npc_HP_hit_dice}]] It'll randomly roll HP for the selected creature and assign it to Bar1 without linking it to the sheet HP value. I have it set as part of my NPC Initiative macro.
Regarding 5e NPC HP, The Aaron has a really great script that I use that will automatically generate HP for the mob as it is added to the map. I use this as well as TokenNameNumber and Group Initiative scripts to really make multiple mob management much easier. <a href="https://github.com/shdwjk/Roll20API/tree/master/Mo" rel="nofollow">https://github.com/shdwjk/Roll20API/tree/master/Mo</a>... <a href="https://github.com/shdwjk/Roll20API/tree/master/To" rel="nofollow">https://github.com/shdwjk/Roll20API/tree/master/To</a>... <a href="https://github.com/shdwjk/Roll20API/tree/master/Gr" rel="nofollow">https://github.com/shdwjk/Roll20API/tree/master/Gr</a>...
1426388123
vÍnce
Pro
Sheet Author
Added read-and-write access to the following properties on the Page object: "lightupdatedrop": True/false value, only update Dynamic Lighting when an object is dropped. "lightenforcelos": True/false value, enforce Line of Sight for objects "lightrestrictmove": True/false value, don't allow objects that have sight to move through Dynamic Lighting walls "lightglobalillumn": True/false value, if true anywhere a token can "see" it is assumed there is bright light present. Added read-and-write access to the "light_multiplier" object on Graphic objects. Just saying... :-P
1426394267
The Aaron
Pro
API Scripter
Yeah, I need to do some updating.
1427608633
The Aaron
Pro
API Scripter
Update v0.8.1 -- Added support for Multi-line commands via {{ }}, light_multiplier, startup version logging, and config API Button. You can now use the multiline syntax for your TokenMod commands: !token-mod {{ --set light_radius|40 light_dimradius|0 light_multiplier|1.5 layer|objects --flip showname --off light_otherplayers --set bar1_value|25 bar2_value|Foe --ids @{target|target 1|token_id} @{target|target 2|token_id} @{target|target 3|token_id} }} An API startup, it will now log out the version number and last update date: "-=&gt; TokenMod v0.8.1 &lt;=- [Sun Mar 29 2015 00:40:56 GMT-0500 (CDT)]" This will get updated as I make further changes (coming soon to all my scripts!) The Help menu is reorganized a bit, and there is now a toggle button for turning on/off Players Can IDs.
1427609525
vÍnce
Pro
Sheet Author
Thanks for the update Aaron. Much appreciated.
The blessings of the church of Aaron has spread farther! Your Scriptomancy skill has increased by 0.2. You gain 375 XP. Your Fame has increased by 250. Your Intelligence has increased by 12. Your Wisdom has increased by 6. You have learned the skill "Think outside the Box".
1427631677
The Aaron
Pro
API Scripter
=D
1430020870
The Aaron
Pro
API Scripter
Update v0.8.2 -- Added multiple status markers. I haven't updated the help for it yet, but basically, anything that works for a single status works for one with an index. The first command here sets the blue status marker on with a number of 1. The second line adds a second blue status marker and sets it's value to 2: !token-mod --set statusmarkers|blue:1 !token-mod --set statusmarkers|blue[2]:2 You can use an empty set of brackets to add a new marker: !token-mod --set statusmarkers|blue:1|blue[2]:2|blue[]:3 Just like other status operations, you can add all of these at once: !token-mod --set statusmarkers|blue:1|blue[2]:2|blue[]:3 Markers are indexed from 1 starting at the left most marker of a particular type. New markers are added to the right, so multiple markers can be interspersed as you like.
Awesome Aaron. Thanks.