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

Dividing the Result of a Complex Macro

Hi all. Struggling with this one... I'm sure it's about the placement of the / modifier. I want to make dice rolling for NPCs (my own game system) a bit more streamlined by creating a quick "number of successes" following the generation of the number of dice from character sheets and inserted options: &{template:default} {{name=@{selected|token_name} }}  SKILL USE [[ ((?{Level|    Expert,4|    Primary,3|    Secondary,2|    Tertiary,1|    None,0|} + ?{Adv/Dis?|0} + ?{Assist?|0})d6) +2d6 - 10 - @{Selected|Wounds}|0)) ]] I can get the total score to display okay, but cant seem to get that score to be divided by 3.5 to replicate the average score of a d6. Anyone have any ideas, or have I exceeded the abilities of the macros lol. Regards, Phil
1753635826
GiGs
Pro
Sheet Author
API Scripter
In standard roll20 macros, you can use the roll only once to generate one total - you cant show n average result, and a separate roll. You can use the Reusing Rolls technique to get around this sometimes. But your brackets and line breaks are confusing me.
1753649079
Gauss
Forum Champion
Hi Phil,  Could you elaborate on what you are trying to do here? Please simplify it to basic math without using Roll20 macro code.  Example: X (0-4) + AD + Yd6 (Assist) + 2d6 - 10 - Z (Wounds) Where X is a number between 0 and 4 (inclusive) AD is "Adv/Dis"?? What does this do?  Y is the number of assist dice And Z is a simple numeric value starting at 0 (and going up from there I assume?).  Nothing here indicates where 3.5 comes into it. 
Hi, sorry for the confusion. The players roll their level in d6's (Expert, Primary, etc), add 2d6, and +/- d6 from "Advantages/Disadvantages" or "Assistance". That total score has 10 and the number of Wounds they have deducted from it. That bit works fine with the above macro. But... I then want to divide that result by 3.5
1753719622
timmaugh
Forum Champion
API Scripter
If you take your roll and wrap it in another inline roll bracket set *in the same computational pass* (not referring to a roll marker like $[[0]]), you can get the divisional/average output you're looking for, yet still also later refer to your original roll. Something like: [[ [[ ...your original roll equation, here... ]]/3.5 ]] Then, for the purposes of showing the results of either of these computations, if this is the *first* roll in your command line, you can refer to the INNER roll (what you originally had) as $[[0]] and the outer roll (where you divide by 3.5) as $[[1]]. If there are other rolls before this one, you might have to adjust those indices accordingly. So, for instance: &{template:default} {{name=@{selected|token_name}  SKILL USE }} [[ [[ ((?{Level|    Expert,4|    Primary,3|    Secondary,2|    Tertiary,1|    None,0|} + ?{Adv/Dis?|0} + ?{Assist?|0})d6) +2d6 - 10 - @{Selected|Wounds}|0)) ]] ]] {{Original Roll=$[[0]] }} {{Divided Roll=$[[1]] }} Something like that...
Thats great, thank you :)
I also added FLOOR to get rid of the decimal places :)
1753736074
Gauss
Forum Champion
Yup, Timmaugh's solution is the way. :) Unless you are using rolls which have to be factored in and out the best way is to do all the calculations in one go, then pull the parts as desired. 
Yes, it was the order of the brackets I'd missed... [[   ]] at each end was the winner :)