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

Is there a way to use a macro or whatever within a journal character to give random hit points?

January 20 (10 years ago)
What I am interested in is something so that when I drag a token from my journal, and place it on the screen, it will give random hit points to it, such as 8d6 or whatever. Is this possible?
Unfortunately you can't "set" values within the Macro system. You'd be able to generate a number of HP, but you would not be able to assign it to the token or sheet.

To edit values you require the API, which is accessed via Mentor level subscriptions.
January 21 (10 years ago)
Thanks for the reply Mark G. I wouldn't mind upgrading if indeed this was a benefit of doing so. Does what I am looking for seem possible if I upgrade to Mentor level? Thanks again for your help
January 21 (10 years ago)
The Aaron
Pro
API Scripter
Yup!

https://gist.github.com/shdwjk/941cee5942ac4275d9ea
January 21 (10 years ago)
The Aaron
Pro
API Scripter
You might also like: https://app.roll20.net/forum/post/1273423/script-tokennamenumber-automatic-numbering-of-qualifying-tokens#post-1514011
January 21 (10 years ago)
Thank you Aaron. This looks great. I must confess that I am new to scripts and API. Do I copy/paste this somewhere for it to work or how do I use it?
January 21 (10 years ago)
The Aaron
Pro
API Scripter
Wiki instructions: https://wiki.roll20.net/API:Use_Guide

I would like to write better instructions, but basically follow those instruction in the first part to get to the API scripts page. Then you just copy and past a script into the editor window, give it a name, then click "Save Scrip". That script is now active. To add a second script, click the new script tab, paste in the script, name it, and click "Save Script".

Keep doing that as you just adding scripts. If you find you don't want a script to be active, you can click disable script. Then you can re-enable it later. If you don't want it for sure, just click delete script, confirm, and it's gone.

I have to apologize for the MonsterHitDice5e script as it is a bit hackish. If you're playing DnD5e and using the npc character sheet, it should work fine for you out of the box. Just let me know if you need help!
January 21 (10 years ago)
I really appreaciate your guidence Aaron. Thank you!
January 21 (10 years ago)
Ok Aaron. I have saved the script. I have a token for a Beholder that I have linked to it's journal. How and where do I input it's hit dice of 19d10 + 76? Do I create an Attribute or something?

January 21 (10 years ago)
The Aaron
Pro
API Scripter
So, if you're playing DnD5e, and using the NPC sheet to setup your monsters (that's what I do), you just put the expression in the HP Hit Dice field of the sheet and it pulls it out and uses it. If you aren't doing that, you can make an attribute on the character and put it in there. If you use the attribute name "npc_HP_hit_dice", it will just work (this is where the character sheet stores it). If you want to use something else, just change where it says 'npc_HP_hit_dice' on line 18 to say 'MyStatName' or whatever you named your stat.
January 21 (10 years ago)
Thanks for the clarification Aaron. It now works perfectly! :)))
January 21 (10 years ago)
The Aaron
Pro
API Scripter
great!!
January 21 (10 years ago)
Hey Aaron, I changed lines 30 and 31 to bar1 instead of the original bar3 - well because I like green... It now is generating hit points in both bar 1 and 3. Any advice? LOL
January 21 (10 years ago)
vÍnce
Pro
Sheet Author
I would try changing this line as well.
line 14.
&& '' === obj.get('bar3_link') ) {
January 21 (10 years ago)
Thank you Vince and Aaron! I am now a happy man.