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

Re-using dice rolls

1600560998

Edited 1600561178
Hi folks, Still new here so bear with me. I recently stumbled on the bit of code which allows you to re-use dice rolls so of course I did what any self respecting tinkerer would do and happily started toying around with it. On it's own, I could get the code to work as advertised but when I dropped it into the end of my template, it refused to return the sum of the dice rolls. Following the same format from the original thread ( &amp;{template:default} [[ [[1d20]] + [[1d6]] + [[6]] ]] {{name=My Attack}} {{$[[0]] + $[[1]] + $[[2]]==$[[3]]}}) , I dropped the code in at the end of my macro: &amp;{template:atkdmg} {{rname=[x]( <a href="https://i.imgur.com/ninIZB4.jpg" rel="nofollow">https://i.imgur.com/ninIZB4.jpg</a> )}}{{mod=@{charisma_mod} + @{pb}}}{{r1=[[1d20cf&lt;1cs&gt;20+@{charisma_mod}+@{pb}]]}}{{{(dis)advantage|Normal,normal=1|Advantage,advantage=1|Disadvantage,disadvantage=1}}}{{r2=[[1d20cf&lt;1cs&gt;20+@{charisma_mod}+@{pb}]]}}{{attack=1}} {{range=Butt end}} {{damage=1}}{{dmg1flag=1}} {{dmg1=[[1d4+@{charisma_mod}+@{Grayson Stonereach|pb} ]]}} {{dmg1type=Blunt}}{{dmg2flag=1}}{{dmg2=?{Hex|No,0|Yes,[[1d6]]|}+[[[[2d4]]*@{HoarFrost_Tracker}]]+?{Cloak|No,0|Yes,[[1d6]]}}}{{dmg2type=Force / Cold / Necrotic}}{{crit1=CARD}} {{crit2=PLEASE!!!}} {{hldmg=hldmg}}{{charname=Range: 10 feet}} {{desc=&nbsp; &nbsp;$[[2]] + $[[3]] = $[[4]] }} While it does capture the damage (10 &amp; 6 in the example below), I can't get it to return the total. Here is the output: I've tried adjusting the code above to "= $[[5]]" but it returns, " INVALID INLINE ROLL! " If someone could please point me in the right direction, it would be most appreciated!! Thanks in advance :)
1600561505
Andreas J.
Forum Champion
Sheet Author
Translator
This page have commented all the stuff people have written about it so far: <a href="https://wiki.roll20.net/Reusing_Rolls" rel="nofollow">https://wiki.roll20.net/Reusing_Rolls</a> Here is the megathread for the topic: <a href="https://app.roll20.net/forum/post/9091992/reusing-rolls-megathread/" rel="nofollow">https://app.roll20.net/forum/post/9091992/reusing-rolls-megathread/</a> I don't understand it well enough to be able to help more concretely.
Thanks Andreas, I did give that a read through as well but couldn't find anything that helped there. Would you recommend I move this post over to that thread instead?
1600575209
Oosh
Sheet Author
API Scripter
Are you trying to add dmg1 and dmg2? This isn't possible, since they're in separate template fields, and you can't perform further operations on the $[[0]] calls.
Ahh there's the issue. Yep, I was trying to add dmg1 and dmg2 ~ thanks Oosh, I'll see about maybe storing the rolls as an attribute and then calling them to the total. Thanks!!
1600588112

Edited 1600588251
Oosh
Sheet Author
API Scripter
Yeah, you can't store any values without API unfortunately. Putting everything in the one damage field is really the only way to get a grand total: &amp;{template:atkdmg} {{rname=[x](<a href="https://i.imgur.com/ninIZB4.jpg)}}{{mod=@{charisma_mod}" rel="nofollow">https://i.imgur.com/ninIZB4.jpg)}}{{mod=@{charisma_mod}</a> + @{pb}}}{{r1=[[1d20cf&lt;1cs&gt;20+@{charisma_mod}+@{pb}]]}}{{?{(dis)advantage|Normal,normal=1|Advantage,advantage=1|Disadvantage,disadvantage=1}}}{{r2=[[1d20cf&lt;1cs&gt;20+@{charisma_mod}+@{pb}]]}}{{attack=1}} {{range=Butt end}} {{damage=1}}{{dmg1flag=1}} {{dmg1=[[ [[1d4+@{charisma_mod}+@{pb}]][WEAPON] + ?{Hex|No,[[0]]|Yes,[[1d6]][HEX]} + [[2d4*@{HoarFrost_Tracker}]][FROST] + ?{Cloak|No,[[0]]|Yes,[[1d6]][CLOAK]} ]]}} {{dmg1type=Blunt}} {{crit1=CARD}} {{crit2=PLEASE!!!}} {{charname=Range: 10 feet}} {{desc=$[[3]] Bludgeoning $[[4]] Force $[[5]] Cold $[[6]] Necrotic}} Something like that. May be worth noting that you don't have the any global fields called in the macro, so global mods won't be added. Another couple of things: the @{rtype} Attribute can be called instead of having to write your own Advantage Query. It replaces the start of the r2 roll as well, so @{rtype}cs&gt;20cf&lt;1 + @{charisma_mod} + @{pb}]]}} after the {{r1}} field, will save you a bunch of typing. It's also a good habit to use the @{d20} Attribute instead of the hard coded d20 rolls, as this will let your macros work with Halfling Luck, expanded crit ranges etc. without having to rewrite them all. If your crit range is the max number on the die, and fumble is 1, you also don't need to supply the cs and cf range, as that's already the default behaviour - saving you a little more typing!