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 .
×
May your rolls be merry + bright! 🎄
Create a free account

Modifier field with "+" breaks rolling syntax

1676155093

Edited 1676177848
Daniel C.
Sheet Author
My D&D_OED sheet (Original Edition Delta) expects to positive ability modifier and attack bonus field showing a '+'. For example: the attack bonus might be "+5". However, this breaks the standard rolling syntax. For example, this... <button type="roll" value="You rolled [[1d20 + @{attack_bonus}]] to hit!" name="roll_attack"></button> ... is broken, in that any positive bonus (e.g., "+5") always results in a roll of zero (0); whereas a zero or negative bonus works as expected.If the field leaves out the '+' (e.g., "5" instead), then the roll button also works as expected. What's the easiest way to parse an integer field with a '+' sign in the context of a roll button like this?
1676160844

Edited 1676161310
Gauss
Forum Champion
Not a character sheet coder, but Roll20 has always had issues with double math signs and the solution has always been to enclose the value in parenthesis. Wrapping the field in parenthesis should work here.  Example: 1d20++5 will not work but 1d20+(+5) will work
1676161818
GiGs
Pro
Sheet Author
API Scripter
That means you need <button type="roll" value="You rolled [[1d20 + (@{attack_bonus})]] to hit!" name="roll_attack"></button> Generally its a good idea to wrap any individual attributes in parenthesis (anything starting with @{ ), especially if those attributes are calculated through an autocalc.
1676177832

Edited 1676177859
Daniel C.
Sheet Author
The extra parentheses fixed it, thanks a bunch!