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

Compare and take greatest?

1426718111
Kryx
Pro
Sheet Author
API Scripter
Is it possible to compare two formulas and take the greatest? <input class="" type="number" name="attr_AC_calc" value="@{armoractive1}+@{armoractive2}+@{armoractive3}+@{armoractive4}+@{armoractive5}+@{armoractive6}+@{armoractive7}+@{armoractive8}+@{armoractive9}+@{armoractive10}"> <input class="" type="number" name="attr_AC_no_armor_calc" value="10+@{dexterity_mod}+floor(@{unarmored_class_bonus})+@{armoractiveunarmored1}+@{armoractiveunarmored2}+@{armoractiveunarmored3}+@{armoractiveunarmored4}+@{armoractiveunarmored5}+@{armoractiveunarmored6}+@{armoractiveunarmored7}+@{armoractiveunarmored8}+@{armoractiveunarmored9}+@{armoractiveunarmored10}"> Is it possible to compare and take the greater of the two? Not looking to use the API - just the normal sheets.
1426718879
Sungrass
Plus
Sheet Author
Would {0d0 + @{attr_AC_calc}, 0d0 + @{attr_AC_no_armor_calc}}kh1 work?
1426719251
Kryx
Pro
Sheet Author
API Scripter
I need it as the value of another input. It does not seem I can do the kh1 trick there as that requires rolling.
1426719950

Edited 1426719999
Diana P
Pro
Sheet Author
(ceil((A-B)/10000000000)*A - floor((A-B-1)/10000000000)*B) gives the higher of the two values A or B So with simple substitution..... :) Though I'm not sure how it would function if you need it as part of a roll later...
1426720907
Stephen Koontz
Forum Champion
Marketplace Creator
Sheet Author
API Scripter
Compendium Curator
Diana P. said: (ceil((A-B)/10000000000)*A - floor((A-B-1)/10000000000)*B) gives the higher of the two values A or B So with simple substitution..... :) That's clever.
1426739903
Lithl
Pro
Sheet Author
API Scripter
Diana P. said: (ceil((A-B)/10000000000)*A - floor((A-B-1)/10000000000)*B) gives the higher of the two values A or B So with simple substitution..... :) Though I'm not sure how it would function if you need it as part of a roll later... Or you could use (((@{A} + @{B}) + abs(@{A} - @{B})) / 2) for max(A, B). Change "+ abs" to "- abs" for min(A, B). That will work even if the difference between A and B is greater than 10 billion. And, frankly, looks less weird. =P
1426741222
Diana P
Pro
Sheet Author
/em hides the rest of her formulas. Then you don't want to see how I really use the less-than variant of my formula. It gets worse once I add the rest of the stuff in. :) But it works how I want it to so I'm happy. :)
1426757358
Kryx
Pro
Sheet Author
API Scripter
Brian said: Or you could use (((@{A} + @{B}) + abs(@{A} - @{B})) / 2) for max(A, B). Change "+ abs" to "- abs" for min(A, B). This is great! Simplified by removing 1 set of parenthesis: ((@{A} + @{B} + abs(@{A} - @{B})) / 2)
1427001548
Chad
Sheet Author
Some of these give problems when used in roll template output and in rolls, any chance we could get full support for all these functions in the roller and the templates?