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

Is there a clever trick to reuse a roll within two sums?

I have a character in a 5e D&D game with an ability that lets me add a d4 to my attack rolls. Because the d4 should not be rerolled when I attack with advantage, I'm hiding the d4 roll by putting it outside all the properties in my roll template, and then I'm reusing the result by index. My macro currently looks like this (without the line breaks): @{Patrick Smith|wtype}&{template:atkdmg} [[1d4[LABEL]]] {{mod=+@{Patrick Smith|spell_attack_bonus}}} {{rname=Warhammer}} {{r1=[[@{Patrick Smith|d20}cs>20 + @{Patrick Smith|charisma_mod}[CHA] + @{Patrick Smith|pb}[PROF]]] + $[[0]]}} @{Patrick Smith|rtype}cs>20 + @{Patrick Smith|charisma_mod}[CHA] + @{Patrick Smith|pb}[PROF]]] + $[[0]]}} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d8 + @{Patrick Smith|charisma_mod}[CHA]]]}} {{dmg1type=Bludgeoning}} {{crit1=[[8[CRIT]]]}} {{globalattack=@{Patrick Smith|global_attack_mod}}} {{globaldamage=[[0]]}} {{globaldamagecrit=[[0]]}} {{globaldamagetype=@{Patrick Smith|global_damage_mod_type}}} @{Patrick Smith|charname_output} My preference would be to include the reused roll within the overall attack roll, so that I could have just a single number, but I gather it's not possible to put a reused roll within another roll.  I think that makes it impossible for me to include the result in both sums, but maybe I'm missing something clever?  One of the examples in the wiki shows capturing an entire roll along with each of its parts to reuse both the parts and the sum. Using that trick, I can do this: @{Patrick Smith|wtype}&{template:atkdmg} [[@{Patrick Smith|d20}cs>20 + @{Patrick Smith|charisma_mod}[CHA] + @{Patrick Smith|pb}[PROF] + [[1d4[LABEL]]][LABEL]]] {{mod=+@{Patrick Smith|spell_attack_bonus}}} {{rname=Warhammer}} {{r1=$[[1]]}} @{Patrick Smith|rtype}cs>20 + @{Patrick Smith|charisma_mod}[CHA] + @{Patrick Smith|pb}[PROF]]] + $[[0]]}} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d8 + @{Patrick Smith|charisma_mod}[CHA]]]}} {{dmg1type=Bludgeoning}} {{crit1=[[8[CRIT]]]}} {{globalattack=@{Patrick Smith|global_attack_mod}}} {{globaldamage=[[0]]}} {{globaldamagecrit=[[0]]}} {{globaldamagetype=@{Patrick Smith|global_damage_mod_type}}} @{Patrick Smith|charname_output} This shows me the first roll as a single number, but the second roll still has two parts to manually sum. Has anyone come up with anything clever to solve this?
1678779367
GiGs
Pro
Sheet Author
API Scripter
You can put an inline roll outside the {{ }} brackets, then call the indices inside the brackets. So you can do this: @{Patrick Smith|wtype}&{template:atkdmg} [[ [[1d20]] + [[1d4]] ]] {{first index=$[[0]]}} {{second index=$[[1]]}} {{total =$[[2]]}} This is a generic example, because I am not familiar with your sheet or the attributes you are using. But hopefully this helps.
1678791919

Edited 1678791939
timmaugh
Forum Champion
API Scripter
Each roll can be involved in only one summation. You can deconstruct the summation to it's component parts elsewhere in your macro (like GiGs showed), but with standard roll20 syntax you can't use a roll in another siloed summation (ie, not nested with the original). With scripts, this becomes easier. ZeroFrame would let you do this. I haven't studied your command too closely, but it looks like you want to reference your 1d4 in a couple of different rolls. ZeroFrame will let you: &[[0]].value ...along with a couple other tweaks to the line. If scripts are available (eg, the game was created by a Pro subscriber) and you want to go this route, post back ad I can work up the full example.
Alas, I'm fairly confident the game was not created by a subscriber. Oh well. Thanks for confirming that what I want is impossible (without paying), and I shouldn't beat my head into a wall trying to come up with something to solve it. I'll instead modify what my goals are into something possible.
1678887753
GiGs
Pro
Sheet Author
API Scripter
Um... the question you asked in OP is totally possible. Check back over my post. Time was suggesting other ways of doing it if you were Pro.
1678897001
timmaugh
Forum Champion
API Scripter
I might be misunderstanding, but I think Pi wants to do something else, GiGs. You're describing deconstructing a roll down to it's parts: &{template:default}{{name=Deconstructing Rolls}}{{Full Roll=[[[[1d10]] + [[1d20]]]]}} {{Roll 0= $[[0]]}} {{Roll 1= $[[1]]}} {{Roll 2= $[[2]]}} I think Pi is wanting to actually use one of those deconstructed parts in another roll: &{template:default}{{name=Deconstructing Rolls}}{{First Summation Roll=[[[[1d10]] + [[1d20]]]]}} {{Second Summation Roll= [[$[[0]] + 1d4]] }} Which you can't do without a script helping you.
Here's a somewhat simplified version of the macro I'm currently using: &{template:atkdmg} [[1d20 + 5[CHA] + 4[PROF] + [[1d4[LABEL]]][LABEL]]] {{r1=$[[1]]}} {{r2=1d20 + 5[CHA] + 4[PROF]]] + $[[0]]}} The macro produces something like this: Mousing over the 13 displays: Rolling 1d20cs>20 + 5[CHA] + 4[PROF] + 1[LABEL] = (3)+5+4+1 Mousing over the 23 displays: Rolling 1d20cs>20 + 5[CHA] + 4[PROF] = (14)+5+4 Mousing over the 1 displays: Rolling 1d4[LABEL] = (1) These are already using the same d4 roll with separate d20 rolls. My goal, which I believe is impossible (without paying), was to keep the same functionality, but to display r2 the same as r1 is displayed. Actually…in a truly ideal scenario, I would want the same functionality, the same display for both left and right (matching what's currently on the left), and I would want the displayed text when mousing over to read like this: Rolling 1d20cs>20 + 5[CHA] + 4[PROF] + 1d4[LABEL] = (3)+5+4+(1)
1678923670
Gauss
Forum Champion
Other than having to manually add the number in, is there a reason not to use the global attack modifier field?