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

Is it possible to do calculations using $[[x]] results?

I'm using the the trick of nesting rolls to gain multiple results from a single roll button: [[ @{una} + ?{Bonus|0} + [[ [[[[1d10]]]] -  [[1d10]] ]] ]] {{black=$[[1]]}} {{red=$[[2]]}} {{difr=$[[3]]}} {{result=$[[4]]}}] So this gives me two separate 1d10 rolls (black and red) as well as the natural difference between them (difr) and the difference after stat and bonus are added (difr). Is it possible to make actual calculations using the $[[x]] elements? I'd like to show the result of the sum stat+bonus+black, which might only be doable with something like {{total= [[ @{una} + ?{Bonus|0} + $[[1]] ]]}} but this doesn't resolve. Can it be done, or is this a limit of the technique?
1602008552
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Unfortunately, this is not possible with the current state of the trick. You can do math using them when doing rolls with the "/r xdy" syntax, but then you can't use the nice looking roll templates.
Thought as much, thanks for the confirmation. I'll just lose the black and rearrange, that'll suffice.
1602016994
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
With what you have, you could actually do this by doing some math and then inverting it in the next layer: [[ @{una} + ?{Bonus|0} + [[ [[ [[ [[1d10]]+@{una}+?{Bonus}]]-@{una}-?{Bonus}]] -  [[1d10]] ]] ]] {{black=$[[0]]}} {{red=$[[3]]}} {{difr=$[[4]]}} {{stat+black+bonus=$[[1]]}} {{result=$[[5]]}}
Cheers Scott. In the meantime I'd actually managed it myself this way: [[ [[ [[[[1d10]] + @{una} + ?{Bonus|0} ]] -  [[1d10]] ]] - @{una} - ?{Bonus|0} ]] {{black=$[[1]]}} {{red=$[[2]]}} {{result=$[[3]]}} {{difr=$[[4]]}} {{diffr=$[[5]]}}
1602034871
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Great to hear. One note, you've got your indexing off by 1. Remember that the rolls are 0-indexed, meaning that the first roll (your first 1d10) is actually $[[0]].