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

Can you check for matching dice on a reused roll?

Ok, so here is what I am trying to figure out: [[5d8m]] will roll the dice and highlight matching dice. [[5d8mt]] will output the number of matching sets. Is there any way to get the second roll to use the results from the first roll to show the number of matching sets? I have tried to get it to work using reused rolls (using $[0] for in place of the first roll), but it doesn't seem to work in any way I can put the second roll together.
Nobody has a method to do this?
1768363109
timmaugh
Forum Champion
API Scripter
Are scripts available? If so, I can do that.
There are some scripts in the game, but I am a player and not the GM, so I don't know exactly which are being used.
1768407807
timmaugh
Forum Champion
API Scripter
OK... so if you can get your GM to install the Metascript Toolbox into your game, you can run something like this: !&{template:default} {{name=Matching Die Roll Info}} {{Base Roll = [[5d8m]]}} {{Expanded=$[[0]].expanded}}{{Match Sets={&r}{{&eval}getDiceByVal($[[0]] >0 all list|,){&/eval}}mt{&/r} }}{&simple} That uses the default template to display the information, and uses the same roll to drive everything. You see the roll result, the "roll tip result equation" without having to hover over the roll, AND you see the number of matched sets: The actual re-using of the roll is happening here: {&r}{{&eval}getDiceByVal($[[0]] >0 all list|,){&/eval}}mt{&/r} What we're trying to do is build a new roll that is formatted like this: [[ {2,3,7,3,1}mt ]] ...which is a format that works to present the number of matched sets from the numbers supplied. So if we can just get the dice from the original roll as our set of numbers, we can construct this format. Breaking down where/how we get the dice and construct the roll, it looks like this (with comments): {&r} | metascript syntax for "start roll"; effectively: [[   { | brace included in secondary roll syntax (opening the set of numbers)     {&eval} | Plugger EVAL tag opening       getDiceByVal | Plugger getDiceByVal function; gets dice if their value matches criteria         ( | Opening paren of gDbV function           $[[0]] | Roll we want to re-examine           >0 | Criteria for values that qualify (anything over 0; e.g., all dice)           all | The set of dice to look at (all vs included vs dropped vs crit, etc.)           list|, | How to output, and the delimiter to use for the chosen option "list"         ) | Closing paren of gDbV function     {&/eval} | Plugger EVAL tag closing   }mt | brace and "mt" roll syntax for secondary roll (closing the set of numbers) {&/r} | metascript syntax for "end roll"; effectively: ]] Since metascripts are still scripts (and because they would seek to alter what would hit the chat), this has to be used in an API message (starting with a bang: "!"). In this case, since I wanted to see what the result of the manipulation was I included the "{&simple}" tag to output the message to chat. (If I were instead going to pass the result to another script, I wouldn't include that {&simple} tag.) Post back if anything is unclear or you need more help applying it to your specific situation.