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

Please add the Min() and Max() functions to those supported in value calculations for sheets

1405113379

Edited 1405113542
Thaddeus R.
KS Backer
Currently it is impossible to auto generate the secondary values for some game systems correctly. Adding support for min() and max() functions would solve some of these. To be as clear as possible, I am talking about functions where two value parameters are passed in and the result that is returned is either the maximum or minimum of the two values.
1405114689
Sam M.
Pro
Sheet Author
Yes please! Writing the math only version of these is cumbersome.
1405120219

Edited 1405120278
Gauss
Forum Champion
You can currently do min() and max() of two or more values by using the keep/drop system. min = {a, b}kl1 max = {a, b}kh1
1405121860
Sam M.
Pro
Sheet Author
That doesn't work for autocalculated sheet values, I've tried.
1405121994

Edited 1405122285
Gauss
Forum Champion
Oh, perhaps there is a bug or order of operations problem then. What is failing to work? Do you have an example?
1405123120
Sam M.
Pro
Sheet Author
I don't think autocalculated values are meant to do dice logic like that at all. It's definitely not in the wiki. If you wanna try, make a sheet with <input type="number" name="attr_test" value="{3,1}kh1" disabled/> and I'm 99% sure the field will be blank.
1405125056
Lithl
Pro
Sheet Author
API Scripter
Thaddeus, I've re-created all of the functions/constants in the JavaScript Math library as auto-calculated values for character sheets over in the CSS Wizardry thread (except for fround, imul, and random). Max/min, specifically, can be implemented as: <input type="hidden" disabled="true" name="attr_max" value="(((@{x} + @{y}) + abs(@{x} - @{y})) / 2)" /> <input type="hidden" disabled="true" name="attr_min" value="(((@{x} + @{y}) - abs(@{x} - @{y})) / 2)" /> As Sam says, it's more cumbersome than simply writing max(@{x}, @{y}) , but the option is open to you.
1405131544
Gauss
Forum Champion
Ahhh ok, I will point this thread out to the Devs.
Thank you everyone for your feedback on this. I will take a look at that thread Brian, thank you very much. I had assumed abs was not supported since I didn't see it in the list and I hadn't gotten around to testing it. It would certainly be nice if all these functions were supported natively in the future, but for now I'll make due with the longer version.
Ok, so even with being able to compute a max(), I'm having trouble with a particular case that I thought I would lay out here in case anyone else had a similar issue My current issue deals with the Palladium system. Some stat bonuses start with a number higher than one. I'm at a bit of a loss how to handle this without conditional logic since the bonus goes from 0 to 2 and then increases by 1 from that point on.
1405436818

Edited 1405436963
Thaddeus R.
KS Backer
I came up with a solution since I last posted which I will share below. Hopefully if any of you have a better solution you will share yours :). I solved the conditional logic by creating a multiplier variable which either contains 0 or 1. The example html is below: <tr><td>IQ:</td><td><input type="number" name="attr_iq" title="iq"/></td> <td> <input type="hidden" disabled="true" name="attr_iq_thresh" value="(((@{iq} + 16) - abs(@{iq} - 16)) / 2)" /> <input type="hidden" disabled="true" name="attr_iq_mult" value="((((@{iq_thresh} - 15) + 0) + abs((@{iq_thresh} - 15) - 0)) / 2)" /> +<input type="text" name="attr_iq_sk_bonus" title="iq_sk_bonus" disabled="true" value="((@{iq} - 14) * @{iq_mult})"/>% all skills </td> </tr> This can be condensed to the logic below where 'm' is my multiplier and x is the final calculated bonus: m = max((min(iq, 16) - 15), 0) x = (iq - 14) * m The result is any attribute value below 16 will result in a multiplier value of 0 and as we all know, anything times 0 is 0. Meanwhile anything 16 or higher results in a multiplier of 1 which is also fairly self explanatory. I hope this helps some other people with similar issues.
Are you able to make rolls using this value? I was able to use the abs() function to get a value to be current, but when I tried to make any rolls using that value it choked. I'm really hoping for min() and max() to be implemented so I can improve my L5R sheet.
1405896960

Edited 1405896989
Lithl
Pro
Sheet Author
API Scripter
Nick, the only way you can use functions like that for the number of dice would be to combine the /roll command with inline rolls. For example: /roll [[(((@{x} + @{y}) + abs(@{x} - @{y})) / 2)]]d10 The above is functionally equivalent to what you're looking to achieve with /roll max(@{x}, @{y})d10 were it available.
1405907003
Umbra
Sheet Author
Nick, I managed to get it working in our campaign. Following Brian's advice above, putting double brackets around the attribute names in the roll itself, ie /roll [[@{Earth}]]d10!! and so forth.