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

How to apply floor/ceil function to roll result?

I'm wanting to round the final roll result up or down depending on the action taken. In the macro below, the result needs to be divided by 2 then rounded up. /em @{selected|character_name} JUMPS [[ (@{selected|agi}+@{selected|gymnastics}+?{+Modifier|0|1|2|3|4|5|6|7|8|9|10}-?{-Modifier|0|1|2|3|4|5|6|7|8|9|10})d6>5 /2 ]] meter(s) into the air!
1621934516

Edited 1621935232
Ziechael
Forum Champion
Sheet Author
API Scripter
Once the calculation is wrapped in a pair of brackets you can prefix it with ceil or floor as needed: /em @{selected|character_name} JUMPS [[ ceil( [[@{selected|agi}+@{selected|gymnastics}+?{+Modifier|0|1|2|3|4|5|6|7|8|9|10}-?{-Modifier|0|1|2|3|4|5|6|7|8|9|10}]]d6>5 /2 ) ]] meter(s) into the air! Of potential interest to reduce the number of queries you are using as well: Using a single query with a user inputted value is often better than a +/- pair of queries... wrapping that in yet more brackets will prevent users from breaking the calculation should they include an additional + symbol: /em @{selected|character_name} JUMPS [[ ceil([[@{selected|agi}+@{selected|gymnastics}+ (?{Modifier|0}) ]]d6>5 /2) ]] meter(s) into the air! You can then extend it further if you wanted to cap the potential modifier to 10: /em @{selected|character_name} JUMPS [[ ceil([[@{selected|agi}+@{selected|gymnastics}+( { ?{Modifier|0} ,10}kl1 )]]d6>5 /2) ]] meter(s) into the air! Side note: all of the above will fail silently should the resulting number of d6s be a negative value but that will at least stop your characters from jumping negative distance lol!
Thanks works perfectly! I have the pos and neg modifiers in two separate drop downs because I've found it cuts down on the amount of math ppl have to do when figuring the final dice pools, but I appreciate the suggestion! Thanks again!
1622017466
Ziechael
Forum Champion
Sheet Author
API Scripter
You are most welcome and if the two query thing works then absolutely don't 'fix' it :D Happy rolling... or jumping... or both!