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

Stopping an action if i don’t have points

So my character has a psionic heal ability. He has to spend points to activate it. These are the two scripts i use to heal and deduct my points.  Is there a way to prevent the heal if there is not enough points? some type of if then statement perhaps? !ammo @{selected|token_id} character_isp +[[{(@{selected|character_isp|max}-@{selected|character_isp}),[[2d6]]}kl1]] S.D.C. !ammo @{selected|token_id}  character_isp  -6 I.S.P.
1610593475

Edited 1610593580
Oosh
Sheet Author
API Scripter
Assuming that first line is the heal, and it costs 6 ISP, you can multiple the heal by this: [[ceil({@{selected|character_isp}-5,0}k1/1000)]] There's other ways to do it, but that will give you 0 for an ISP value less than 6, and 1 for any other value up to 1000. I'm assuming that's high enough to never get a 2, just add more zeroes if not. !ammo @{selected|token_id} character_isp +[[[[ceil({@{selected|character_isp}-5,0}k1/1000)]]*{(@{selected|character_isp|max}-@{selected|character_isp}),[[2d6]]}kl1]] S.D.C.
Awesome. I plugged it in and it works awesome. If you have a minute can you explain why it worked? i am still learning code in general and roll20  so a few things are unclear. what does !ceil signify. i understand the labels but the math evades me. 
1610744974
Kraynic
Pro
Sheet Author
Breaking down the top snippet that Oosh posted: floor(calculation here) means to round the calculation result down.  ceil(calculation here) means to round the calculation result up. {calculation here,calculation here}kl1 means to resolve both sides of the comma independently and then keep the lowest one. Since ceiling is telling the /1000 to round up, any number above 0 and below 1001 in the isp - 5 part of the calculation will resolve a value of 1.  Anything below that will resolve to 0.  That result is being multiplied against the rest of your calculation to provide healing (on 1) or not (on 0).
I see.  its purely a math problem then. You arent telling it to not heal or do heal you are making the equation multiply the dice roll by 1 or 0 which the output would be =dice roll or 0 Fascinating.  But why -5 in the -5,0 part of the equation?
1610756687
Kraynic
Pro
Sheet Author
Because you should still be able heal if you have 6 ISP.  If you use -6, that would result in a 0 result of the equation and no healing.  The way Oosh has it set up, it is checking for is that you have MORE than 5. Personally, I just put ISP on a token bar for psions so that they are visible.  Depending on the character though, I can see how you might run out of bars to display things.
Ohh i see so if i use this code for another ability with a cost 3 ISP I would put -2  the k1 commands i have seen are  kl1 kh1 for keep the lower or higher of two numbers. What does just k1 signify.  !ammo @{selected|token_id} character_isp +[[[[ceil({@{selected|character_isp}- 2 ,0}k1/1000)]]*{(@{selected|character_isp|max}-@{selected|character_isp}),[[2d6]]}kl1]] S.D.C.
1610764202
Kraynic
Pro
Sheet Author
The wiki has a lot of info on macros and the dice roller. k1 is shorthand for kh1 (keep highest 1). <a href="https://wiki.roll20.net/Dice_Reference" rel="nofollow">https://wiki.roll20.net/Dice_Reference</a> <a href="https://wiki.roll20.net/Complete_Guide_to_Macros_%26_Rolls" rel="nofollow">https://wiki.roll20.net/Complete_Guide_to_Macros_%26_Rolls</a>
lol there is shorthand for the abbreviation?&nbsp; Thank you for the info and the link i will check it out and get some of the basics down.