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

How to make one roll automatically reference the result of a previous roll?

October 18 (1 year ago)

I'm looking for a way to make the values of one roll change depending on the result of a previous roll without just typing out the two rolls separately


For example if I rolled  10d6 and wanted the end value to be only the number of sixes. I would want the next roll to be Xd6 where X is the number of sixes that was rolled in the first roll.
So if I rolled 4 sixes out of the 10d6, I would want the next roll to roll 4d6. If I rolled 2 sixes out of 10d6, I would want the next roll to be 2d6 ect, any help?

October 18 (1 year ago)
timmaugh
Forum Champion
API Scripter

Answering your specific question, you can use a roll like this to have the number of 6s rolled on 10d6 be the number of d6 you then roll:

[[[[10d6>6]]d6]]

If you later need to refer to the individual "sub" rolls independently, you can by using the "re-using rolls" trick. Basically, you can "unpack" sub-rolls of a more complex roll... so you can do something like this (where the main roll is made "off-screen" -- between template parts -- so that it doesn't show up until I want it to):

&{template:default}{{name=Roll Check}}[[[[10d6>6]]d6]] {{Roll 0=$[[0]]}} {{Roll 1=$[[1]]}}

If you can't include the rolls the rolls you need as parts of a more complex roll so that you can later reuse them (for instance, if you need to reuse a particular roll as the basis for multiple further rolls) then you're starting to get into the realm of scripts. But, for what you specifically want to do, the above should work.

October 18 (1 year ago)


timmaugh said:

Answering your specific question, you can use a roll like this to have the number of 6s rolled on 10d6 be the number of d6 you then roll:

[[[[10d6>6]]d6]]

If you later need to refer to the individual "sub" rolls independently, you can by using the "re-using rolls" trick. Basically, you can "unpack" sub-rolls of a more complex roll... so you can do something like this (where the main roll is made "off-screen" -- between template parts -- so that it doesn't show up until I want it to):

&{template:default}{{name=Roll Check}}[[[[10d6>6]]d6]] {{Roll 0=$[[0]]}} {{Roll 1=$[[1]]}}

If you can't include the rolls the rolls you need as parts of a more complex roll so that you can later reuse them (for instance, if you need to reuse a particular roll as the basis for multiple further rolls) then you're starting to get into the realm of scripts. But, for what you specifically want to do, the above should work.


This does work for what I need, however I was hoping to be able to swap out the '10' of 10d6 in my example with [[2*@{Unit Size}]] which hasn't worked

'Unit Size' is a number that changes in the attributes section of the sheet, any idea how to add this in?

October 18 (1 year ago)
timmaugh
Forum Champion
API Scripter

You just have to enclose the math portion of that... you can do it in parentheses OR another inline roll, depending on what else you might need to do:

Parentheses:

[[[[(2*@{Unit Size})d6>6]]d6]]

Inline Roll:

[[[[[[2*@{Unit Size}]]d6>6]]d6]]