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 .
×

Saving Throw with Modifiers macro

Trying to create a macro that will show a critical success/fail with a variable modifier. I've tried this: [[1d20+?{Bonus?|0}cf<9cs>10]] but it doesn't show the crit fail/success outlines. If I move it to the end: [[1d20cf<9cs>10+?{Bonus?|0}]] then it shows the cf/cs outlines, but it doesn't adjust for the total value. So if I roll an 8 or 9, with a +2 bonus, it would show 10 and 11 as failures (even though they should be successes).
1791165440

Edited 1791165489
Gauss
Forum Champion
Hi Solana,  If I understand correctly you want to have the red or green boxes. Correct?  If so, we need to do things a bit differently.  [[1d[[{1d20+?{Bonus?|0},0d0}>10]]cf<0cs>1]] What this does:  {1d20+?{Bonus?|0},0d0}>10 If the total of 1d20+modifier is equal to or greater than 10 it results in a "1".  If not, it is a "0" Then, the 1 or 0 is put into this part:  [[1d[[0 or 1]]cf<0cs>1]] And that turns it into a 1d0 or 1d1 roll.  1d0 is always 0, so that becomes red 1d1 is always 1, so that becomes green
Hi Gauss, Thank you for this! Is there no way to set it up to show the actual final result of the die roll? This is workable, but I'm just curious. Thanks!
1791180200

Edited 1791182418
Gauss
Forum Champion
I was afraid that is where you were going to go with it. There are two options:  1) Modify the above, then make a Template where you pull the result out.  2) Use a Success/Failure style Rollable Table, then set it in a template.  Here is an example of #1:  &{template:default} {{name=Example}} {{Roll=$[[0.computed]]}} {{Red/Green=[[1d[[{[[1d20cf<0cs>21+?{Bonus?|0}]],0}>10]]cf<0cs>1]]}} While the above is accurate, I realized I was overthinking it. This should give you exactly what you want:  [[1d20cf<[[{9-(?{Bonus?|0}),0}kh1]]cs>[[{10-(?{Bonus?}),1}kh1]]+?{Bonus?}]] Explanation:  1d20cf<9cs>10 is an inequality, similar to X<Y in math. It is solvable.  So if something is on one side we can subtract it from that side and put it on the other.  In this case: (1d20+modifier)<9 and (1d20+modifier)>20 becomes: (1d20)<(9-modifier) and (1d20)>(10-modifier) But because this is Roll20 we have to do some other things to make it work out, the above is just the math concept.  [[1d20cf<[[{9-(?{Bonus?|0}),0}kh1]]cs>[[{10-(?{Bonus?}),1}kh1]]+?{Bonus?}]] First, we wrap the query in parenthesis because we are using subtraction. This protects against a negative bonus. Roll20 doesn't like double negatives.  Second, we need to put a limit on how low these modifiers will take the 9 and 10. Below 0 and things break.  Since anything below 0 is going to be a failure and anything above a 1 is going to be a success, we can cap them off with keep high (kh1). {9-(?{Bonus?|0}),0}kh1 and  {10-(?{Bonus?|0}),1}kh1 Next, wrap them in inline brackets to get them to process before the cf< and cs> process.  [[{9-(?{Bonus?|0}),0}kh1]] and [[ {10-(?{Bonus?|0}),1}kh1]] Finally, we add back in everything else:  [[1d20cf< cs>  and +?{Bonus?} Giving us:  [[1d20cf<[[{9-(?{Bonus?|0}),0}kh1]]cs>[[{10-(?{Bonus?}),1}kh1]]+?{Bonus?}]] Note: we don't need to put |0 in every query, just the first. It will reuse the first query's output. 
Thank you, Gauss! I'll be honest, I only partially understood the explanation, but from what I did understand, I think I get how it works... Either way, I've just tested it in-game, and it does exactly what I want, so thank you very much! And now I have saved it in my backup with the rest of my coding tricks for future use!