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

Need help with a formula for my Short-Rest Macro

!wammo @{selected|character_id} hit_dice -?{Hit Die|} Hit Die !setattr --name @{selected|character_name} --mod --hp|+[[?{Hit Die}d@{selected|hitdie_final}]]| !setattr --silent --sel --class_resource|@{selected|class_resource|max} I have a macro that rolls hit die and adds the rolled amount to the players hp bar but as of right now it will give them too much hp if they roll more than their max and they have to go back through and reset it to their max number.  Ex. Player has 15hp. Takes 10hp in damage and now has 5hp. Rolls 12hp on the hit die during a short rest. The macro makes his hp 17 instead of stopping at 15, the max.  Does anyone know if I can create a formula to prevent it from surpassing the characters max hp value?
1585091974
GiGs
Pro
Sheet Author
API Scripter
Replace hp in the following with the name of the actual hp attribute, and hp_max with the max for that attribute (which is usually the same name with _max appended). --hp|[[{hp_max+0d0,hp+?{Hit Die}d@{selected|hitdie_final}}kl1]] This  {a roll,another roll}kl1 says keep the lowest one. So it if hp are above max, it keeps max instead. We need to add +0d0 on the first term, to make both numbers into dice rolls, since operations like these need both quantities to be the same kind  of thing - either both numbers, or both rolls.
GiGs said: Replace hp in the following with the name of the actual hp attribute, and hp_max with the max for that attribute (which is usually the same name with _max appended). --hp|[[{hp_max+0d0,hp+?{Hit Die}d@{selected|hitdie_final}}kl1]] This  {a roll,another roll}kl1 says keep the lowest one. So it if hp are above max, it keeps max instead. We need to add +0d0 on the first term, to make both numbers into dice rolls, since operations like these need both quantities to be the same kind  of thing - either both numbers, or both rolls. I wasn't able to get that to trigger correctly. But, I did figure out a way to achieve my desired outcome.  Using ChatSetAttr I added the --modb command, which contains the value between 0 and its max.  !wammo @{selected|character_id} hit_dice -?{Hit Die|} Hit Die !setattr --modb --silent --sel --hp|+[[?{Hit Die}d@{selected|hitdie_final}]]
1585096924
GiGs
Pro
Sheet Author
API Scripter
Nice! I always forget chatsetattr has different ways of calling it.
First time I've actually used that command for it I think. Extremely useful now that I know it's there.