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

Conditional Statements via math Question

So I'm poking at the conditional statement (math) formula that is on the useful macro wiki page and was wondering if it would allow me to do something which I'm just not formulating correctly or if it just isn't possible. What I want the formula to do is figure out if a player's stat is above or below 0, and depending on that it changes what amount of dice are rolled. It looks like the formula can spit out two results so I'd be testing if Stat < 0 with the results being Stat if true and 2 if false, but I'm unsure of how/if it can then roll that answer in d6.
1699317398

Edited 1699317614
Gauss
Forum Champion
Hi Chesh,  It is *possible*, but I would need more information.  Which character sheet are you using?  Which stat is required? What are the breakpoints and the results of each breakpoint?  Example:  0-5 = 0d6 6-10 = 1d6 11+ = 2d6 and so on. 
1699317592

Edited 1699317682
No sheet, just using the default attribute system with stats that will always be whole numbers. If you just need an example one of the stats is named Power. I'm not sure what you mean by breakpoints? If it's when the formula becomes 2d6 instead of Statd6 then that would be at 0
1699317650

Edited 1699317684
Gauss
Forum Champion
Looks like you responded before I was finished editing, could you supply the breakpoints? (Last edit I provided an example)
We keep beating each other to the punch. Like I edited before I'm not quite sure what you mean but if it is when the roll is meant to become 2d6 instead of [stat]d6 that would be at 0 and lower
1699317854
Gauss
Forum Champion
Ok, so if I understand correctly:  If the stat is <=0 then it is 2d6 If the stat is 1+ then it is Xd6 where X is equal to the statistic?
Gauss said: Ok, so if I understand correctly:  If the stat is <=0 then it is 2d6 If the stat is 1+ then it is Xd6 where X is equal to the statistic? Yes, this exactly. I think I understand the math theoretically but I'm not sure I'm formatting it correctly for r20 when I try to make the macro
1699318344

Edited 1699318897
Gauss
Forum Champion
Here you go: /r ([[{?{stat},0}>1}]]*(?{stat}-2)+2)d6 You can replace /r with inline brackets "[[ ]]" if you so desire.  Replace ?{stat} with the attribute name in both locations. I was using a query as my pseudo-attribute for testing. How it works:  This part checks the stat, if the result is 1+ the answer is a "1", if the result is 0 or less the answer is a "0": [[{?{stat},0}>1}]]  Then, the result is multiplied by: (?{stat}-2) This gives you either a 0 (if the result is 0) or the stat minus 2 (if the result is a 1). The reason for minus 2 is for the next step.  Next step: +2 This gives you your baseline of 2 dice. So if the result was 0 you have 2 dice. If the result is 1 you have stat-2+2 = stat Finally, the d6 is added to it all
This works exactly like I needed! Thank you very much for the help!