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

Empty Input type number breaks calculation

April 07 (10 years ago)

Edited April 07 (10 years ago)
Kryx
Pro
Sheet Author
API Scripter
Is there a way to prevent input type number being blank causing the whole roll to fail other than setting a default of value="0" on the input?
Example:
<input class="sheet-no-spin" type="number" name="attr_acrobatics_bonus" value="0" step="1">

<input class="sheet-no-spin" type="number" name="attr_acrobatics" value="2+3+@{acrobatics_bonus}" disabled="disabled">

<button type="roll" name="roll_Acrobatics_Check" value="[[ d20 + @{acrobatics} + (0) ]]"></button>
"attr_acrobatics_bonus" is the one that I would like to remove the value="0" on as having 0s show up is ugly.

The result is
[[ (13)+(2)+(3)++(0)]]
Which results in 0.

If I wrap @{acrobatics_bonus} in parenthesis it causes the "attr_acrobatics" calculation to be blank. When I tried this strategy elsewhere I sometimes got errors about having the closing parenthesis without a number.

Is there a different way to do this or must I set value="0" on all number inputs?
April 07 (10 years ago)

Edited April 07 (10 years ago)
Gauss
Forum Champion
"++" and "--" (minus minus) cause the roll to fail.
My guess is that you have and extra + somewhere. Perhaps in the attribute @{acrobatics_bonus}. I suggest finding the extra plus and removing it.
April 07 (10 years ago)
Diana P
Pro
Sheet Author
The only way you can leave the input blank and still have it work is to have the expectation that the user enters the + or - along with the number.

You would then need to have your calculation look something like value="[[ d20 @{acrobatics} ]]" so that when a +3 gets substituted in for the @{acrobatics} it will resolve to [[d20 +3]] .

In that circumstance, it will ignore the @{acrobatics} value if you do not put the operator in there ie [[d20 3]] resolves to [[d20]] .

This solution, of course, has it's own issues in that the equations start looking odd and you do have to remember to put the +3 in for the entered value so is not the correct one for everyone to use.
April 07 (10 years ago)

Edited April 07 (10 years ago)
Kryx
Pro
Sheet Author
API Scripter
@Gauss it has ++ because the input type number is blank, not 0.

It seems that 0 has to be there always. Ugly 0s is a much better solution than requiring pluses.

Thanks for the reply though Diana.
April 07 (10 years ago)
Gauss
Forum Champion
Ahhhh, ok.