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

Pick the closest to 10 of two die rolls

I want to roll 2d20 and have my macro only display the one that's closest to 10. I feel like the only way to do this would require me to store the roll results in variables, but I don't know if that's actually possible in the macro system. Is there a way to do this, or would I be better off writing this in a different program?
I want to get the result closest to 10, regardless of whether it's higher or lower. If I rolled my 2d20 and got a 15 and a 3, I would want to take the 15 because its difference from 10 is 5, and the difference for 3 is 7. As far as I can tell, this would require using absolute value and making comparisons to variables, which I don't know are possible in roll20's macro system.
1529871896
vÍnce
Pro
Sheet Author
I see. That might require powercards.
1529877295
GiGs
Pro
Sheet Author
API Scripter
Do you always roll 2d20, and is the number you are comparing them to always 10?  As long as that's true, and any modifiers are applied only after comparing the two dice to 10, you could do it with a table. you'd need to work out the weights of each number, which isn't too hard. If any of those constraints I mentioned aren't true, the table approach wouldn't work.  I cant think of any other way to do that without using the API, a pro feature.
1529889048

Edited 1529889189
Here's a messy way that's possible with an inline roll...but it won't give the actual value of the die, just how far it was from 10, so it may not be what you're looking for. The nearest roll to 10 was equal to 10±[[{ [[abs([[1d20]]-10)]],[[abs([[1d20]]-10)]] }kl1]]
The table method will work. Otherwise, I think I can just program it somewhere else. Thanks!