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

Versus Test (Mouse Guard) macro troubleshooting request

For context:  this will be used as a "versus test" macro for Mouse Guard 2e. I am trying to write a macro that will ask for a Skill Name (which it does), Ask for Side A's base rating and modifiers (which it then uses to be Xd6s, which it does).  Then does the same for Side B (still good here).  Then I want it to compare Side A's and Side B's successes (greater than 3), determine a winner, and report the margin/delta between the two (neither thing works consistently).   &{template:default} {{name=?{What is the skill name?} Versus Test}}{{A_Successes=[[ (?{Side A base}+?{Side A mod|0})d6>3 ]]}}{{B_Successes=[[ (?{Side B base}+?{Side B mod|0})d6>3 ]]}}{{Margin=[[$[[0]]-$[[1]]]]}} The image below shows two outputs from different iterations that I've tried: In the top one, the successes carry over, but no math happens, and there are visible brackets.  In the second, the line is outside the template, and just prints, it doesn't do either thing. Any recommendations would be appreciated.
My image didn't seem to post.  Mea culpa.
1756747717
Gauss
Forum Champion
Hi Kevin P.,  To confirm, you'd like three lines, with the third line being the difference between lines 1 and 2? If so:  &{template:default} {{name=?{What is the skill name?} Versus Test}} [[[[ (?{Side A base}+?{Side A mod|0})d6>3 ]]-[[ (?{Side B base}+?{Side B mod|0})d6>3 ]]]]{{A_Successes=$[[0]]}} {{B_Successes=$[[1]]}} {{Margin=$[[2]]}} What I am doing: all the calculations are happening between the sections, then via reusing rolls I am displaying the results. 
Ah!  That's exactly right.  Thank you! Can you explain how your code differed from what I had (just for my own learning)?
1756777559

Edited 1756777622
Gauss
Forum Champion
You tried to perform math on reused rolls , you can't do that. :) Going to simplify it here:  A + B = C So what you did was to put A and B inside inline brackets, then call those as reused rolls in C and try to sum them. That won't work.  Example of what you did: (note: I am using subscripts so you can keep track of things a bit better) Output A = [[A 0 ]] Output B = [[B 1 ]] Output C = [[$[[0 A ]] + $[[1 B ]]]] <---- won't work, you cannot sum reused rolls.  So instead I did all the calculations first, then called them.  [[ [[A 0 ]] + [[B 1 ]] ]] Output A = $[[0 A ]] Output B = $[[1 B ]] Output C = $[[2 A+B ]] That is represented here in bold:  &{template:default} {{name=?{What is the skill name?} Versus Test}} [[[[ (?{Side A base}+?{Side A mod|0})d6>3 ]]-[[ (?{Side B base}+?{Side B mod|0})d6>3 ]]]]  {{A_Successes=$[[0]]}} {{B_Successes=$[[1]]}} {{Margin=$[[2]]}} You can see that is between {{name=}} and {{A_Successes=}} but it is still part of the template, just not visible.  Alternately, I can stick the entire calculation in Margin and use a different variation of reusing rolls to pull it to earlier in the template.  &{template:default} {{name=?{What is the skill name?} Versus Test}} {{A_Successes=$[[0.computed]]}} {{B_Successes=$[[1.computed]]}} {{Margin= [[[[ (?{Side A base}+?{Side A mod|0})d6>3 ]]-[[ (?{Side B base}+?{Side B mod|0})d6>3 ]]]] }}
1756780815
timmaugh
Forum Champion
API Scripter
I'll just jump in to say that as a Pro user, Kevin P., you have the ability to install scripts. Installing the MetascriptToolbox would give you a greater power to reuse rolls as you initially tried. There are quirks to be aware of with that method, but there are also times when the stock Roll20 syntax just won't get you where you need to go. (For instance, using a stack of calculations for comparisons against multiple simultaneous target values). In that case, you can't (short of some RainbowEncoder magic, perhaps) create a conglomerate roll of all parts put together which you then refer to, later, in parts.... but you could use the Toolbox syntax to reuse them in a more intuitive way. If you're open to that sort of approach, I can offer a modification to your command line that would illustrate the usage. If you're not open to it, I won't clutter the thread with unwanted syntax/approach.
Okay, thank you both very much for your help! That might be interesting to me at a latter date, but not at the moment, Timmaugh.