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.

Could be a GitHub issue as I'm not seeing the new version in your gists profile <a href="https://gist.github.com/shdwjk" rel="nofollow">https://gist.github.com/shdwjk</a>
1414563971
The Aaron
Roll20 Production Team
API Scripter
Ah! good catch. User error, I accidentally overwrote one of my other scripts. All fixed now and the forum is updated! Thanks for the help!
Ahh ok! Anyhow, using the Dungeons 5e character sheet by @Actoba and with your script I can now easily enter the HP for my monsters/npcs using: !token-mod --set bar1|[[@{selected|npc_HP_hit_dice}]] Thanks! This will speed up things quite a bit =)
1414591102

Edited 1414591429
The Aaron
Roll20 Production Team
API Scripter
Great! BTW, if you want the monsters to have unique hit dice rolls, I have this other script that could be modified to roll the hit dice as the creatures are added to the VTT (It's an older script and a bit less user friendly than I try to be, but maybe you'll find it useful...): GIST: <a href="https://gist.github.com/shdwjk/7377de58100f4e813432" rel="nofollow">https://gist.github.com/shdwjk/7377de58100f4e813432</a> For your case, you'd change line 22 to read: name: 'npc_HP_hit_dice' and then it should work.
Would anyone using this basically have to change line 22 from name: 'HitDice' to name: 'npc_HP_hit_dice' And lines 36, 37 to bar1 instead of bar2?
Hehe, just saw your edit confirming my question.
1414591570
The Aaron
Roll20 Production Team
API Scripter
Yup, you are correct. I should really give this a bit of an overhaul. I'm ashamed of any scripts I write that require manual editing to configure them. =D
Incredible. Thank you for all the work.
1414595714
The Aaron
Roll20 Production Team
API Scripter
Thanks! Glad you like! Let me know if there are specific additions you'd like. =D
You've done all the heavy lifting for modifying tokens in a condition and time management script my friend and I are working on. Will likely make your script a dependency.
Aaron, I need some help with your MonsterHitDice script. Basically, I have tried copy pasting a monster graphic that is already linked to the NPC sheet, or dropping a graphic by grading the NPC sheet to the map area, and both methods didn't work. Am I missing something to trigger the conditions on the script? If needed I can give you GM access to troubleshoot it.
1414604151
The Aaron
Roll20 Production Team
API Scripter
No worries, PM me an invite and I'll come see. I haven't used that script in a long time, so it's possible something has broken..
1414604206
The Aaron
Roll20 Production Team
API Scripter
sturtus said: You've done all the heavy lifting for modifying tokens in a condition and time management script my friend and I are working on. Will likely make your script a dependency. Cool. If there are some interfaces you need exposed, I can do that, just let me know. =D
Thanks for the ver 4.0 Hope to put it to use soon! Jim
1414694615
The Aaron
Roll20 Production Team
API Scripter
No worries! =D
1414733529

Edited 1414736702
The Aaron
Roll20 Production Team
API Scripter
Here's a sample macro for applying a 5th Edition DnD Potion of Healing to a token. /em applies a Potion of Healing to @{target|Target|token_name} !token-mod --set bar3_value|[[{@{target|Target|bar3}+2d4+2, @{target|Target|bar3|Max}d1}kl1]] --ids @{target|Target|token_id} This will emote the action, then adjust the hit points of the token by the amount of the healing potion, or set it to the maximum for the bar. (This assumes bar3 is where your hit points are, but you can adjust it as needed.) For this to work, you need to turn on the players-can-ids setting: !token-mod --config players-can-ids|on
The Aaron said: Here's a sample macro for applying a 5th Edition DnD Potion of Healing to a token. /em applies a Potion of Healing to @{target|Target|token_name} !token-mod --set bar3_value|[[{@{target|Target|bar3}+2d4+2, @{target|Target|bar3|Max}d1}kl1]] --ids @{target|Target|token_id} This will emote the action, then adjust the hit points of the token by the amount of the healing potion, or set it to the maximum for the bar. (This assumes bar3 is where your hit points are, but you can adjust it as needed.) For this to work, you need to turn on the players-can-ids setting: !token-mod --config players-can-ids|on This rocks! I am trying to modify this for D&D 4e healing Word. /em You utter a soothing Healing word at @{target|Target|token_name} !token-mod --set bar1_value|[[{@{target|Target|bar1} +1d6 + @{target|Surge Value}, @{target|Target|bar1|Max}d1}kl1]] --ids @{target|Target|token_id} I have the HP on the Bar1 and healing surges on Bar2. I can get the macro to add 1d6 plus the Surge Value to Bar1, but I can't figure out how to remove 1 surge from Bar2. Help! please. Jim
1414780980

Edited 1414784555
The Aaron
Roll20 Production Team
API Scripter
Should be something like: /em You utter a soothing Healing word at @{target|Target|token_name} !token-mod --set bar1_value|[[{@{target|Target|bar1} +1d6 + @{target|Surge Value}, @{target|Target|bar1|Max}d1}kl1]] bar2_value|[[{@{target|Target|bar2}-1, 1d0}kh1]] --ids @{target|Target|token_id}
I get "Cannot mix M and sum rolls in a roll group"
1414785584
The Aaron
Roll20 Production Team
API Scripter
Ah.. that old chestnut... Try this: /em You utter a soothing Healing word at @{target|Target|token_name} !token-mod --set bar1_value|[[{@{target|Target|bar1} +1d6 + @{target|Surge Value}, @{target|Target|bar1|Max}d1}kl1]] bar2_value|[[{@{target|Target|bar2}-1, 0}kh1]] --ids @{target|Target|token_id}
Works! That's awesome! Thank you.
All the math is done in the background, is their away to show the rolls?
1414787074
The Aaron
Roll20 Production Team
API Scripter
Not yet, but I was just telling Bryce a little while ago that I've got some ideas for that… v0.5 feature!
Good, looking forward to v0.5. Happy Halloween!
1414847938

Edited 1414848330
Aaron, I didn't see a way, but can you set token representation? The use case is that with this macro I could very easily create a set of macros that will automatically setup tokens the way I want in essentially 1 click. For example for NPC that are using token numbering script: !token-mod --set represents|"?{name?}" name|"?{name?} %%NUMBERED%%" bar3_value|@{selected|npc_hp} bar3_max|@{selected|npc_hp} bar2_value|@{selected|npc_ac} --on showname You could do something similar with PC as I have basically used this to also replace your !torch script (reducing the number of scripts), so it would simply be similar to above then a second press to set vision on the token. I also assume there is no way in the API to set the default token of a character journal is there, because that would realistically be the last piece that I personally do when setting up tokens. As it is now I can do all of that except setting representation, so either way it is an awesome script as usual.
1414850385
The Aaron
Roll20 Production Team
API Scripter
Hi Kevin! Currently, there isn't a way to set represents in the script, but it's completely possible with the API and I'll add it in the next iteration. You are correct regarding setting the representative token on a character sheet. I'd really like access to that for numerous reasons!
The Aaron said: Hi Kevin! Currently, there isn't a way to set represents in the script, but it's completely possible with the API and I'll add it in the next iteration. You are correct regarding setting the representative token on a character sheet. I'd really like access to that for numerous reasons! +1
How do I utilize this API to increment bar values? I understand how to 'set' but if I wanted to make a bar be reduced by 1 or ?{Number} how which command is that? Thank you! (Trying to overcome my idiocy!)
Whoops! I found my answer. Thanks!
1415191040
The Aaron
Roll20 Production Team
API Scripter
Great! I'm working on a syntax for incremental changes as well as result printing which will make that use case easier and more useful.
1415814998
chatty
KS Backer
Sheet Author
I sort of stumbled into this thread, and I feel like I am down a rabbit hole of utility for Roll20. Holy cow. Is the idea here that you create some macros to handle the token functions, or that you just type fast? ;)
1415815712
The Aaron
Roll20 Production Team
API Scripter
Macros, definitely macros! :)
1417026436
vÍnce
Pro
Sheet Author
Is it possible for TokenMod to move a token to a "targeted" square on the grid? Maybe using another token for reference? So, you could place a "crosshairs" token somewhere on the map, select the token you want to move, run a TokenMod macro, and the selected token would move to the new location. Simple as that. :-)
1417026693
The Aaron
Roll20 Production Team
API Scripter
Hmm.. Interesting question. If the Top and Left of a token were exposed to the macro system, you could do it. Unfortunately, they aren't. =/ I can probably add a syntax for that. Let me think about it... Can you detail out your use case, that might help with coming up with a solution. =D
1417028404

Edited 1417028426
vÍnce
Pro
Sheet Author
I started thinking about it when playing around with the Flickering Lights script. I added the effect to a torch carried by a player and while using the group feature (player token and torch) I wasn't able to move because the torch is "locked" in position due to the flickering lights script. You mentioned; The Aaron said: Just got a chance to try this. Pretty cute idea. Vince said: Token's named "TORCH" cannot be moved while !LIGHTFX ON is activeI don't know if it solves any problems for you, but you can move it with my TokenMod script. Just change the 10's to the coordinates (1-biased): !token-mod --set top|[[( 10 *70)-35]] left|[[ ( 10 *70)-35]] I didn't realize your TokenMod script could move tokens. Silly me. So, although it doesn't really solve my issue of "carrying" a torch with the flickering effect (not a big loss), I thought the idea of moving one token to another area of the map just by clicking a square would be handy. I read in another thread that you could probably get the coordinates of a map location using a token that was already there. I guess there's a reason you can't just target an area of the map. I assume it's because it's really just one large token.
1417029879
The Aaron
Roll20 Production Team
API Scripter
You could probably do this with the Carry script.
1417030515
vÍnce
Pro
Sheet Author
The flickering lights effect with a moving token is not a deal breaker. I can group and move w/out the effect. I was more curious about moving one token to another across the map, kind of like your watching your Mark or TurnMarker change from one token to another.
1417030903
The Aaron
Roll20 Production Team
API Scripter
Yeah, it's definitely possible to do that, just not directly with TokenMod.
1417069469
The Aaron
Roll20 Production Team
API Scripter
Update v0.5 -- Added delta changes to all reasonable number fields. You can now specify +3 or -2 instead of just a number, even on status numbers: !token-mod --set statusmarkers|blue:-1 bar1_value|+3 This can be used on any field that is one of: Number, Number or Blank, Degrees, Text, Status Status fields will be bound between 0 or 9, other fields will not be bound. Also added the ability to set the represents for a token. You need only specify the character_id, probably with @{&lt;character name&gt;|character_id}: !token-mod --set represents|@{Bob|character_id} Note that this will clear out any links that bars have currently... So I've also added setting links for the bars, using the fields bar1_link, bar2_link, bar3_link. You need to specify the name of an attribute on the character the token represents. If you're specifying these in the same command as represents, be sure they are after: !token-mod --set represents|@{Bob|character_id} bar1_link|npc_HP bar2_link|npc_ac bar3_link|npc_temp_HP One final caution: There seems to be a bug with updating a token bar via the API when it is tied to an attribute, such that other tokens that are tied to the same attribute do not get updated. Be sure to leave a comment if you experience that, particularly if you can narrow down the case. sturtus said: Hi Aaron. I have a request for your script if you are willing. I'd like the ability to assign linked attributes to a token that represents a character. Input: !token-mod --set bar1_link|npc_AC --set bar2_link|npc_HP Logic: If the token "represents" a character (if not spit an error), Find the ID of the attribute object linked to the name in the command Set the bar1_link to that ID Set the values of the bar according to the ID Worth it? This id done, and looks pretty much like you suggested. You'll want to do a represents|@{SomeChar|character_id} before you set those links, or just set the represents manually (but why would you want to do that!). Kevin said: Aaron, I didn't see a way, but can you set token representation? The use case is that with this macro I could very easily create a set of macros that will automatically setup tokens the way I want in essentially 1 click. For example for NPC that are using token numbering script: !token-mod --set represents|"?{name?}" name|"?{name?} %%NUMBERED%%" bar3_value|@{selected|npc_hp} bar3_max|@{selected|npc_hp} bar2_value|@{selected|npc_ac} --on showname You could do something similar with PC as I have basically used this to also replace your !torch script (reducing the number of scripts), so it would simply be similar to above then a second press to set vision on the token. I also assume there is no way in the API to set the default token of a character journal is there, because that would realistically be the last piece that I personally do when setting up tokens. As it is now I can do all of that except setting representation, so either way it is an awesome script as usual. This is done now, for the most part. I didn't chose to do the name syntax, but I might add that later. For the moment, you'll need to specify it with the @{&lt;character name&gt;|character_id} syntax. !token-mod --set represents|@{Some Char Name|character_id} name|"?{name?} %%NUMBERED%%" bar3_link|npc_hp bar2_link|npc_ac --on showname or if you're making a mook: !token-mod --set represents|@{Some Char Name|character_id} name|"?{name?} %%NUMBERED%%" bar3|@{Some Char Name|npc_hp|max} bar2_link|npc_ac --on showname Let me know if you have any questions!
1417204235

Edited 1417204327
Aaron, Thank you for the update! I do have a question though, with regards to --set represents. I can't seem to find a way to allow macro input to fill in the &lt;character name&gt; in the @{&lt;character name&gt;|character_id}, so it seems you need to hardcode the name into the macro, is this correct, or am I missing something?
1417204345
The Aaron
Roll20 Production Team
API Scripter
Correct. I'll see about taking a character name in addition to a character_id.
1417205383
The Aaron
Roll20 Production Team
API Scripter
Update v0.51 -- Setting represents now supports character names instead of just character_id. You can use the full name (quoted if it contains spaces) or just a partial name that is unique among your characters. It is not case sensitive, so Max = max = MaX = MAX. There ya go Kevin!
Thanks Aaron!!
1417230221
The Aaron
Roll20 Production Team
API Scripter
No problem!
Hey Aaron any plans on adding the Multiplier feature to your script? I'd love to make a macro that cuts the players vision in 1/2 for magical darkness effects :)
1417316389
The Aaron
Roll20 Production Team
API Scripter
Absolutely! I'll add it just as soon as it's exposed to the API. Lasted I checked we don't have access.
1417320177
The Aaron
Roll20 Production Team
API Scripter
Update v0.52 -- Setting Number and Number or Blank can now be decimal. (Thanks Black Falcon)
1417888491

Edited 1417888661
Re: this bug - There seems to be a bug with updating a token bar via the API when it is tied to an attribute, such that other tokens that are tied to the same attribute do not get updated. Be sure to leave a comment if you experience that, particularly if you can narrow down the case. I have been able to replicate this issue. I have 4 targets, and I am adjusting bar 1 of all targets simultaneously 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]] Only the LAST TARGET I choose gets the value. Not sure if you already found this out, but its something. I'll continue fooling around with it to see if I can get anymore specifics for you. Thanks for the awesome script. Note: The issue persists if I rearrange the fields, I.e. switch --ids with --set. Also, I reset the IsGm script and reconfigured myself as GM to rule out that possibility.
1417888759
The Aaron
Roll20 Production Team
API Scripter
I'll have to try that situation. I was browsing the API forum and found a message from about a year ago where Riley was talking about updating attributes that were tied to bars. It might be that I could change it to update the attribute instead of the bar and it would behave correctly. I'll try that and see. Will probably just add direct access to character attributes and such as it's a much requested feature. :) Glad you're getting good use out of it!