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
This post has been closed. You can still view previous posts, but you can't post any new replies.

Min/max functions in mathematical formulas

Hello! Here is a really simple suggestion, that would greatly simplify writing macros and which must be pretty trivial to implement: a min and a max function. When you add the bonus given by two different buffs in a d20 system, you have to make sure that you take the *max* between the two and not the sum, if they are of the same type. Currently, I use (a+b+abs(a-b))/2 to compute max(a,b). That's long and unreadable. That would be great if I could just write max(a,b) and min(a,b) when I need to :-) Best!
1404378718
Gauss
Forum Champion
This can already be done: Max: {a, b}kh1 Min: {a, b}kl1 Link: <a href="https://wiki.roll20.net/Dice_Reference#Keep_.2F_Drop_khN.2FklN.2FdhN.2FdlN" rel="nofollow">https://wiki.roll20.net/Dice_Reference#Keep_.2F_Drop_khN.2FklN.2FdhN.2FdlN</a>
Oh, awesome! Thanks =)
1405910442
Fyndhal
Plus
Sheet Author
I'm trying to figure out if you can do a Min/Max vs "Successes" -- In 5th Edition Shadowrun, you frequently have a maximum number of successes possible on a test (the "Limit"). The Keep values logic doesn't seem to allow me to do that, that I can see. Am I missing something or would this be new functionality?
1405911342
Gauss
Forum Champion
Fyndhal , could you go into more detail on how exactly the roll would work and maybe I can come up with something.
1405939860
Umbra
Plus
Sheet Author
Could just be {DiceRoll, Limit}kl1 where DiceRoll is your regular success calculation and Limit is your Limit. (you might have to do some dice shenanigans like Limitd1 to get it to compute properly) Try that?
1405945228
The Aaron
Roll20 Production Team
API Scripter
Something like this does give you the number of successes or 3, whichever is lower: /r { {10d10&gt;9}, 3 d1}kl1
1406214298

Edited 1406214972
Fyndhal
Plus
Sheet Author
Aaron, that works perfectly, thank you. It's not particularly pretty but put it in a macro and it should work great. EDIT: I got an error in my macro. Here's what I was working with: /me : ?{Action|Fill in} /r { {(?{Attribute|0}+?{Skill|0}+?{Bonus|0}-?{Penalty|0})d6&gt;5s}, ?{Limit|100}}kl1 And this is the error: Cannot mix sum and M rolls in a roll group Is there anyway to work around that limitation? If anyone is wondering, the limit 100 is set arbitrarily high so that when making no limit checks, you can just hit enter at the Limit prompt and it won't cause any issues.
1406216293
The Aaron
Roll20 Production Team
API Scripter
Try: /me : ?{Action|Fill in} /r { {(?{Attribute|0}+?{Skill|0}+?{Bonus|0}-?{Penalty|0})d6&gt;5s}, ?{Limit|100} d1 }kl1
1406216624
Fyndhal
Plus
Sheet Author
Heh...bonehead mistake on my part. Thanks! That works perfectly. I shall go be embarrassed now. :)
1406219614
The Aaron
Roll20 Production Team
API Scripter
meh.. I only know that because I tried the simpler case and remembered someone else pointing it out. It's a bit arcane as syntax goes already, so don't worry about it. =D