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

Defining an attribute in a character sheet from the highest of two variables

So I'm trying to define an attribute for a roll on a character sheet I am working on, but the number won't display regardless of what I do, and I am running out of ability to think coherently trying to figure it out. Can anyone offer some advice? input type="number" name="attr_save_physical" value="{@{strBonus},@{conBonus}}kh1+@{PhysProf}" Essentially I need it to keep the highest of Strength or Con modifier, and add it to another modifier to produce the attribute result.
1474547289

Edited 1474547321
There needs to be a dice expression in the function in order for it to work. See Grouped Rolls Try this [[ {@{strBonus}+0d0 ,@{conBonus}+0d0 }kh1+@{PhysProf} ]] Inline rolls might be a good idea too, try it with and without to see what you prefer. 
1474556304

Edited 1474556782
Thanks for the try, but this still is not working. The number still refuses to display. This is enormously frustrating. For clarification, this is intended to be a disabled input that auto-calculates based on the stat bonuses. I'm not sure if that was clear or not.
Dice expressions don't work inside character sheet input element values. "Note that you can only include attributes from the current Character. You also can't include macros, abilities, or rolls...just basic math such as @{Intelligence}/2+@{Level} . You also have access to the floor, round, and ceil functions, such as floor(@{Intelligence}/2) ." I don't see a way to do this without the API.
Son of a... That seems like an oversight of design, but then I suppose it is a bit of a niche. Thanks.
Aye
1474561870
Diana P
Pro
Sheet Author
You can do math only max and min values: If x &gt; y, the result is x, while if x &lt; y, the result is y &lt;input type="hidden" disabled="true" name="attr_max_xy" value="(((@{x} + @{y}) + abs(@{x} - @{y})) / 2)" /&gt; (pulled from: <a href="https://app.roll20.net/forum/post/882997/css-wizar" rel="nofollow">https://app.roll20.net/forum/post/882997/css-wizar</a>... ) Several existing character sheets use these tricks to calculate things.&nbsp; There are some functions which are more difficult to implement, but max is easily doable. :)
I knew there had to be a formula for this!
1474573623

Edited 1474573701
Lithl
Pro
Sheet Author
API Scripter
Also, a number of the hurdles presented for autocalc fields are easily answered with sheet workers. For example, the same autocalc that Diana posted can be achieved like this: &lt;input type="number" name="attr_x"&gt; &lt;input type="number" name="attr_y"&gt; &lt;input type="number" name="attr_max_xy" readonly&gt; &lt;script type="text/worker"&gt; on('ready change:x change:y', function() { getAttrs(['x', 'y'], function(values) { var x = parseInt(values.x) || 0, y = parseInt(values.y) || 0; setAttrs({ max_xy: Math.max(x, y) }); }); }); &lt;/script&gt; My post Diana linked to was from a time when sheet workers were not a thing. =) In this case, the autocalc version is shorter (if harder to read, IMO), but other parts of that post (such as the trancendental functions) get shorter, easier to read, and &nbsp;more accurate with sheet workers.
1474602346

Edited 1474602846
Diana, that is pretty much exactly what I need, but will it work if the values are equal, or will it freak out? Also, does anyone in this thread have any experience with conditional statements?
1474611024
Diana P
Pro
Sheet Author
It will work if they are equal. What kind of conditional statements are you looking for?&nbsp; (i.e. maybe.... :)
1474612885

Edited 1474616061
I'm trying to make a conditional wherein if the given value is greater than or equal to 0, use(add) an extra value, else use(add) 0. I've been trying to follow the instructions on the wiki but only ended up making my head hurt. Edit: Nevermind, thank you all for your assistance, but my wife figured it out for me.
Care to share your wife's solution?
1477184394

Edited 1477184434
Her solution was: ({{@{X},-1}&gt;0}*(@{Y}+0)+0) Where Y is the value of a given Skill, and X is the character's Proficiency Bonus. If Y is 0 or greater, it adds the Proficiency Bonus to the result of the roll. If it is not, it adds nothing. Sorry it took so long. I am godawful at checking these things.