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

Trying to make a macro to roll HP and put in token's health bar

I was able to successfully get the hit points rolled from the token's character sheet formula, but I'm stuck on actually assigning the rolled value to the current and max values of the token's health bar.  I tried to steal this !token-mod {{ --set statusmarkers|Stealth bar3_current|[[1d20+@{selected|stealth_mod}]] --report gm|"{name} Stealth roll: {bar3_current}" }} !roll20AM --audio,nomenu,play|Stealth From a similar question and adapted it to this (which just fails in complete silence) !token-mod{{   --set     bar3_current|[[@{selected|npc_hpformula}]]     bar3_max|@bar3_current }} but since I cannot find these syntax elements documented anywhere (with the exception of [[@{selected|npc_hpformula}]]), I can't tell what the original is really doing and what's chaff. Any help would be greatly appreciated. Bill
1581389205

Edited 1581389238
GiGs
Pro
Sheet Author
API Scripter
This line isnt a proper attribute reference  bar3_max|@bar3_current It should be  bar3_max|@{bar3_current} Though that likely wont do what you want either because it'll run into order of operations problems. When you run the macro, it grabs all the referenced attribute values at that instance, then goes through and does what the macro does. So that will grab the bar3_current value at the point before the macro was run, not the changed version from the line above. If you want to set current and max to the same value, you should do this !token-mod{{   --set     bar3_current|[[@{selected|npc_hpformula}]]     bar3_max|[[@{selected|npc_hpformula}]] }} Does this work for you?
1581397999
The Aaron
Roll20 Production Team
API Scripter
Also, try using just bar3 instead of bar3_current and bar3_max. It will set both current and max to the same value. 
I'm afraid neither of your suggestions worked.  I tried GiGs individually to bar3_current and bar3_max but no assignments were made to the current or max values; I didn't try both because I figured the script as written would roll the dice twice, once per bar value, definitely not the desired result.  I also tried Aaron's of just assigning to bar3 but that was likewise unsuccessful. With respect to my other question, where are the ! name {{...}} and --set macro elements documented? Thanks, Bill
1581561449
The Aaron
Roll20 Production Team
API Scripter
In the help: !token-mod --help
1581571243
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It can be easier to read the help if you copy the chat output and paste it into a handout. I do this periodically (to account for updates). I also go to the External Journal section of the Content menu of my games home page and bookmark the journal. This allows me to call up the documentation even when outside the game.
Sorry, I'm lost.  Where _exactly_ am I supposed to type '!token-mod --help'?  It doesn't do anything in the chat window, and the help button just brings up the wiki page.  Searching on it doesn't bring up anything useful. On a more fundamental level, though, where is it documented that I _should_ do this to get help?  How did you, Aaron know this?  I can't believe it's all word of mouth.
1581704154
Kraynic
Pro
Sheet Author
You do have TokenMod installed in the api settings page of your game, right?&nbsp; If you do, then that command should bring up a huge amount of info in chat.&nbsp; The Aaron is the author of tokenmod:&nbsp;&nbsp; <a href="https://app.roll20.net/forum/post/4225825/script-update-tokenmod-an-interface-to-adjusting-properties-of-a-token-from-a-macro-or-the-chat-area/?pagenum=1" rel="nofollow">https://app.roll20.net/forum/post/4225825/script-update-tokenmod-an-interface-to-adjusting-properties-of-a-token-from-a-macro-or-the-chat-area/?pagenum=1</a> That thread in the API forum has an awful lot of info in that first post including the help command.
1581707436
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
There is documentation on the API page of your campaign where you (presumably) used the one-click to install the script. That tells you how to get the in-game help as well. And yes, with the script installed and the camaign active, you should only need to type&nbsp; !token-mod --help &nbsp;in the chat window.
Kraynic, That was the "Step 0" I needed.&nbsp; I had no idea that 'token-mod' was not a native macro keyword, nor how to attach API scripts to a game.&nbsp; Now it works. Thanks, all! Bill
1581985638
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The wiki is woefully sparse on documenting this step, leaping right into writing scripts.