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

Plus vs. Minus Signs in Roll Query Inputs

Having an annoying issue that I'm sure someone else must be experiencing and/or have a solution for. I'm using a roll query in a custom character sheet roll button that outputs the roll info to a roll template, like this: <button type='roll' class='combatbutton' value='@{whispertoggle} &{template:custom} {{title=@{banner_surprise} **@{character_title} @{selected|token_name}**}} {{subtitle=Surprise Check}} {{Surprise=[[1d6cs0cf0+@{class_surprise_bonus}[class]-@{has_helm}[helm]+@{mod_surprise}[mod1]+?{Modifier|0}[mod2]]]}}' name='roll_surprise'> Surprise</button> At the end of the {{Surprise}} [[roll]] clause is a roll query that prompts the user for an additional 'Modifier', if any. If the number entered by the user is signed negative, the button roll works as expected. However, if the user enters a plus sign (which is natural for a user to do), it breaks the roll. The output displays as '++' which I suspect is breaking the parser. While the work-around is simply enough ("don't enter plus signs") but people forget and the roll calculations break at the worst times. Any ways to address this?
1694228679
Gauss
Forum Champion
Wrap the query in parenthesis, that will fix the problem. 
1694240400
GiGs
Pro
Sheet Author
API Scripter
You are correct that ++ is breaking ther parser.
Gauss said: Wrap the query in parenthesis, that will fix the problem.  Saved again by GiGs! That worked.  WHY?
1694390000
GiGs
Pro
Sheet Author
API Scripter
It was gauss who pointed it out :) But the parser breaks on two signs, like ++ or --. However, if you put something in parenthesis it is evaluated as a number. So when someone enters the + sign, it gets treated as a sign of the number, not as a separate addition operator. You sometimes have to do this in complex expressions even when they don't include queries.
Thanks!