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

Roll Output using Power Cards and Token Mod

I made a really (really) simple macro to be able to roll and apply heals for the four "Cure" spells in D&D. Run macro, click target, select heal spell, done. The macro applies the heal to the token, but there's two things I can't figure out. 1. How to cap the heal at the max health of the target token 2. How to actually show the output in Powercards. !power {{  --name|Cure Spell  --rightsub|Range: Touch  --hroll|[[ [$C1] 1d8 + @{level} ]] [[ [$C2] 2d8 + @{level} ]] [[ [$C3] 3d8 + @{level} ]] [[ [$C4] 4d8 + @{level} ]]   --api_token-mod|_ids @{target|token_id} _set bar1_current|+?{Type?  | Cure Light Wounds,[^C1] | Cure Moderate Wounds,[^C2] | Cure Serious Wounds,[^C3] | Cure Critical Wounds,[^C4] } }} Any assistance would be greatly appreciated. Thanks!
1610996553

Edited 1610997250
I'm not familiar with Power Cards so can't help with number 2, but for number 1 try changing the token mod command like this (putting in your full query)  --api_token-mod|_ids @{target|Heal|token_id} _set bar1_current|+[[{?{Type?},(@{target|Heal|bar1|max}-@{target|Heal|bar1})}kl1]] Using {value1,value2}kl1 tells it to only add to the bar whichever value is lower. In this case, value2 is the difference between max health and current health. This is also assuming Power Cards will handle the inline roll math after substituting [^C1] or whichever of those values is placed by the query. That script might require a different way to handle the math.
1611000604
Kurt J.
Pro
API Scripter
The following will show the output on the card. Note that I modified the hroll line to include "selected" in front of level, but you can take that out if you are casting from a character sheet ability. The down side is that you can't see what TYPE of spell was cast without more work because the roll query only returns the [^C1], etc. !power {{  --name|Cure Spell  --rightsub|Range: Touch  --hroll|[[ [$C1] 1d8 + @{selected|level} ]] [[ [$C2] 2d8 + @{selected|level} ]] [[ [$C3] 3d8 + @{selected|level} ]] [[ [$C4] 4d8 + @{selected|level} ]]   --api_token-mod|_ids @{target|token_id} _set bar1_current|+?{Type?|Cure Light Wounds,[^C1]|Cure Moderate Wounds,[^C2]|Cure Serious Wounds,[^C3]|Cure Critical Wounds,[^C4]}  --Healing:|@{target|token_name} is healed for ?{Type?|Cure Light Wounds,[^C1]|Cure Moderate Wounds,[^C2]|Cure Serious Wounds,[^C3]|Cure Critical Wounds,[^C4]} Hit points }}
1611000667
The Aaron
Roll20 Production Team
API Scripter
And actually, if you want to restrict a bar's value to between 0 and the max field, you can append a ! to the value: !token-mod --set bar1_current|+23 ! From the instructions: If you are setting a bar value, you can append a  !  to the value to force it to be bounded between  0  and  max  for the bar. This is a fairly recent addition to the capabilities of TokenMod, but is present in the 1-click version.
The Aaron said: And actually, if you want to restrict a bar's value to between 0 and the max field, you can append a ! to the value: !token-mod --set bar1_current|+23 ! I totally missed that functionality somehow, thanks for pointing it out!
1611010593
The Aaron
Roll20 Production Team
API Scripter
Persephone said: I totally missed that functionality somehow, thanks for pointing it out! I don't know how you could have missed it, it's right there in the middle of 1000 lines of documentation... =D
The Aaron said: I don't know how you could have missed it, it's right there in the middle of 1000 lines of documentation... =D LOL well either way, now that I know about it I can make a lot of macros way shorter. Though it doesn't seem to like bars where the max is set at 0 (tried to decrease the current without it going below 0), so in those cases I'll have to stick with a kl1 function ^^'