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

Trying to fix a very simple roll equation.

I'm looking for this function to do a Attribute + Modifier = dice rolled  with all dice of 4, 5, and 6  being counted as successes. It was working fine until I added the >3 at the end. Now it tells me, "Cannot mix sum and success rolls in a single roll expression." I'm new to this, so any advice would be greatly appreciated. :)
1601760744
GiGs
Pro
Sheet Author
API Scripter
First bit of advice: dont post screenshots of code, post the actual text. It makes it much easier for people to copy and edit, to fix for you. I'm not going to type that out from scratch. What I think you need to do it put [[ ]] around the two attribute references.
My apologies. This is the code being referenced: <button name="roll_str" type="roll" value="/r @{strength_base}d6+@{strength_modifier}d6>3" class="txt-btn large">STR</button> Adding [[ ]] resulted in the code appearing as such: <button name="roll_str" type="roll" value="/r @{[[strength_base]]}d6+@{[[strength_modifier]]}d6>3" class="txt-btn large">STR</button> However, I get a syntax error. It's the same with: <button name="roll_str" type="roll" value="/r @[[strength_base]]d6+@[[strength_modifier]]d6>3" class="txt-btn large">STR</button> This is the error in question: SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "s" found.
1601762878

Edited 1601762956
GiGs
Pro
Sheet Author
API Scripter
First thing: in roll20, the > means equal or over . It's confusing, but it doesnt mean  greater than . So to get rolls over 3 (4,5,6) you need to do >4. For your actual problem: You need to put the [[ ]] around both complete attributes, like this: <button name="roll_str" type="roll" value="/r [[@{strength_base}+@{strength_modifier}]]d6>4" class="txt-btn large">STR</button> The [[ ]] makes sure everything within it is calculated first, and then applied to the d6>3 thats outside the brackets. You could also have done this - have two separate >4 expressions: <button name="roll_str" type="roll" value="/r @{strength_base}d6>4 +@{strength_modifier}d6>4" class="txt-btn large">STR</button>
1601762913

Edited 1601762949
Kurt J.
Pro
API Scripter
Danny said: My apologies. This is the code being referenced: <button name="roll_str" type="roll" value="/r @{strength_base}d6+@{strength_modifier}d6>3" class="txt-btn large">STR</button> Adding [[ ]] resulted in the code appearing as such: <button name="roll_str" type="roll" value="/r @{[[strength_base]]}d6+@{[[strength_modifier]]}d6>3" class="txt-btn large">STR</button> However, I get a syntax error. It's the same with: <button name="roll_str" type="roll" value="/r @[[strength_base]]d6+@[[strength_modifier]]d6>3" class="txt-btn large">STR</button> This is the error in question: SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "s" found. The syntax error is happening because [[ ]] indicates an inline roll, but you are trying to pass that to a /roll command, which will end up trying to /roll [[$0]] or something similar. You need to change the way you are grouping your dice in either one of two ways: @{strength_base}d6>3 + @{strength_modifier}d6>3 or (@{strength_base}+${strength_modifier})d6>3 Either one should roll the appropriate number of d6 and count successes. Note that while a base or modifier of 0 will be ok, if you have the possibility of negative numbers, weird things might happen :) Edit: GiGs beat me to it :)
1601763041
GiGs
Pro
Sheet Author
API Scripter
good point - for a roll like this normal brackets ( ) can be used in place of the [[ ]].
Wow. Thank you guys so much! This is very informative and will help me with my sheet.
1601811944

Edited 1601839125
Ziechael
Forum Champion
Sheet Author
API Scripter
Also, your inline brackets were misplaced which may have led to the error: <button name="roll_str" type="roll" value="/r @{ [[ strength_base ]] }d6+@{ [[ strength_modifier ]] }d6>3" class="txt-btn large">STR</button> should be: <button name="roll_str" type="roll" value="/r [[ @{strength_base} ]] d6+ [[ @{strength_modifier} ]] d6>3" class="txt-btn large">STR</button> All of that aside, as Kurt/GiGs says, use () instead for sheet rolls.
1601826204
GiGs
Pro
Sheet Author
API Scripter
Ziechael said: All of that aside, as GiGs says, use () instead for sheet rolls. Well, it was Kurt who first suggested that and I realised I'd omitted the suggestion from my post.