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

Method to Sum Multiple Dice Rolls in Roll Template?

1527170179
Axel
Pro
Sheet Author
I'm a complete novice when it comes to scripting, but I need a way to compare multiple dice rolls, from different attributes, and sum them into one output. I'll use an unrelated example to more easily illustrate what I'm looking for. Imagine that I have a macro that allows me to make multiple attacks and that outputs all the attack rolls and damage rolls in a single roll template. If there are three attacks, I'm dealing with six attributes: one for each attack roll and one for each damage roll. I want a way to show the sum total damage from all successful attacks on that same roll template. I can easily have the roll template only display the damage rolls of successful attacks, but how would I then sum those damage rolls into one variable that is displayed? I know that some systems, such as Fantasy Flight's Star Wars, requires scripts to interpret dice rolls, but is that at all similar to what I need?
1527171860
GiGs
Pro
Sheet Author
API Scripter
This isn't possible without an API script. It cant be done through a rolltemplate or the normal macro system alone.
1527172673
The Aaron
Pro
API Scripter
I think you could do it with a Roll Template by having a heck of a lot of nested comparisons giving you all possible permutations for the number of attacks you support and having inline rolls that add the right values.  Sort of the "If Attack1 hit and Attack3 hit, [[ Attack1 + Attack3 ]]" thing.  Would probably be pretty horrendous but possible.
1527173797
Jakob
Sheet Author
API Scripter
The Aaron said: I think you could do it with a Roll Template by having a heck of a lot of nested comparisons giving you all possible permutations for the number of attacks you support and having inline rolls that add the right values.  Sort of the "If Attack1 hit and Attack3 hit, [[ Attack1 + Attack3 ]]" thing.  Would probably be pretty horrendous but possible. Nope, because you cannot call inline rolls in the roll template, you have to call them in the chat command - your attempt would produce the text [[ ]] surrounding the two inline rolls.
1527174548
Axel
Pro
Sheet Author
This is why I was thinking that I'd most likely need an API script. However, as a novice on scripts, I've had to copy other's work for projects I've done before, so I'm not sure where to start on this one because I'm not sure if anyone else has done this.
1527174607

Edited 1527174986
GiGs
Pro
Sheet Author
API Scripter
Yeah, you cant perform any kind of arithmetic within the roll template itself. It's a pain :) Edit: crossposted with Axel. I don't have time right now to point you in the right direction, but what you want to do is actually pretty simple within an API script.  Look up the inlinerolls property of msg on on the wiki or forum for pointers.
1527174872
The Aaron
Pro
API Scripter
Jakob said: Nope, because you cannot call inline rolls in the roll template, you have to call them in the chat command - your attempt would produce the text [[ ]] surrounding the two inline rolls. Ah, that's a bummer!