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 it possible to use a single die roll's result in multiple places?

I've been working on a new sheet for WH40k Only War (with a friend with a Pro account helping me with testing), and it's been coming along fairly well. One of the features I wanted to add was an extra line on the sheet's rolltemplate. For context, here is a shortened form of a ranged attack roll in the sheet: {{roll=[[floor(( [[@{WS}+@{WS_advancement} + @{R_weapon_trained} - 20 + @{R_weapon_mod1}]] - [[1d100]] )/10)]]}} which produces the Degrees of Success on that attack. The rolltemplate uses the code: {{#^rollLess() roll 0 }}Degrees of Success{{/^rollLess() roll 0 }} {{#rollLess() roll 0 }}Degrees of Failure{{/rollLess() roll 0 }} to differentiate between hit and missed attacks. I wanted to add another property to the rolltemplate that would show if the weapon Jams on a natural roll of 96 or above. However, simply copying this rolltemplate property wouldn't work because the roll value it's checking has already gone through calculations. Is there a way to copy that raw 1d100's result to another value that can be run through another property of the rolltemplate?
1596021566
GiGs
Pro
Sheet Author
API Scripter
The way to do this is to set a fumble range on your roll, and then check of that with the rolltemplate logic functions Change your roll to {{roll=[[floor(( [[@{WS}+@{WS_advancement} + @{R_weapon_trained} - 20 + @{R_weapon_mod1}]] - [[1d100cf>96]] )/10)]]}} Then you can use the rollWasFumble() logic helper.
GiGs said: [[1d100cf>96]] This is an interesting idea, but it wouldn't apply too well to the use case I have in mind. OW actually has several rules, such an "Unreliable" weapon jamming on a 91 or above, a "Fully Automatic" weapon jamming on a 94 or above, and a "Reliable" weapon only jamming on the natural 100. Setting up the fumble range is a really nice solution, but it only really works in one case. If the raw 1d100 value could be copied to another rolltemplate property, I could use the rollBetween() logic helper to manage all of those cases at once.
1596045098
Kraynic
Pro
Sheet Author
You could have the crit fail threshold set as an attribute on the sheet, so that it could be adjusted for different weapons. 
1596045468
GiGs
Pro
Sheet Author
API Scripter
If you need multiple different conditions causing fumbles on the same roll, you can only do that as an API script. If only one such effect applies on any given roll, Kraynics suggestion works - you can also use a query to get the fumble range. [[1d100cf>?{Mishap Range?|96}]]
Well, this works perfectly. Thanks very much!
1596145351

Edited 1596148713
Sammy Silver
Sheet Author
I have a follow-up question, because this was related to the idea of hypothetically copying a die value. The plan is to make a simple "1d100" button. When clicked, it would query the user for a target number, then display in chat the target number, the 1d100 roll's result, then the difference between the two numbers as Degrees of Success. I feel it's a bit more involved than the Jamming function I described before, because the dice value might actually need to be printed twice to make this happen. So far I have something like: <button class='button' type='roll' name='d100' value="&{template:mythic} {{character= @{character_name}}} {{target= [[(?{Target Number?|50})]]}} {{raw_roll=[[1d100]]}} {{difference=[[1d100]] - [[target]]}} ">1d100</button> and then the rolltemplate like {{#target}} <div class="sheet-template-header">{{character}} just rolls a d100 </div> <div class="sheet-template-content"> <div class="sheet-template-row template-center">Target: {{target}} Roll: {{raw_roll}} </div> <div class="sheet-template-row template-center">Difference: {{difference}}</div> </div> {{/target}} but I'm not sure about how to make the Difference code work. Thanks very much for helping me through this, by the way! I really appreciate it!
bump - I understand that this is a new question I'm asking, but it's related to the question as written in the headline and probably isn't worth starting a new thread with the same name over.
I dont think the 'same' dice roll can be used twice like you want. Maybe, but terribly, you could do a roll helper to check it per line item and have a 100 lines for each output.  Copy/Paste would be your friend here.  I would try it with like... a d6 to begin with and see if it works. <button class='button' type='roll' name='d100' value="&{template:mythic} {{character= @{character_name}}} {{target= [[(?{Target Number?|50})]]}} {{raw_roll=[[1d100]]}} {{difference1=[[1-?{Target Number?}]]}} {{difference2=[[2-?{Target Number?}]]}} .... {{difference100=[[100-?{Target Number?}]]}}">1d100</button> {{#target}} <div class="sheet-template-header">{{character}} just rolls a d100 </div> <div class="sheet-template-content"> <div class="sheet-template-row template-center">Target: {{target}} Roll: {{raw_roll}} </div> {{#rollTotal() raw_roll 1}}<div class="sheet-template-row template-center">Difference: {{difference1}}</div> {{/rollTotal() raw_roll 1}}      {{#rollTotal() raw_roll 2}}<div class="sheet-template-row template-center">Difference: {{difference2}}</div> {{/rollTotal() raw_roll 2}}      {{#rollTotal() raw_roll 3}}<div class="sheet-template-row template-center">Difference: {{difference3}}</div> {{/rollTotal() raw_roll 3}} ....      {{#rollTotal() raw_roll 100}}<div class="sheet-template-row template-center">Difference: {{difference100}}</div> {{/rollTotal() raw_roll 100}} </div> {{/target}}
<button class='clear minimisable_infographic_override' type='roll' name='d6' value="@{to-gm}&{template:mythic} {{character= @{character_name}}} {{target= [[(?{Target Number|2})]]}} {{roll= [[1d6]]}} {{difference1=[[1-?{Confirm}]]}} {{difference2=[[2-?{Confirm}]]}} {{difference3=[[3-?{Confirm}]]}} {{difference4=[[4-?{Confirm}]]}} {{difference5=[[5-?{Confirm}]]}} {{difference6=[[6-?{Confirm}]]}} ">1d6</button> {{#target}} <div class="sheet-template-header">{{character}} just rolls a d6 </div> <div class="sheet-template-content"> <div class="sheet-template-row template-center">Target: {{target}} Roll: {{roll}} </div> {{#rollTotal() roll 1}}<div class="sheet-template-row template-center">Difference: {{difference1}}</div> {{/rollTotal() roll 1}} {{#rollTotal() roll 2}}<div class="sheet-template-row template-center">Difference: {{difference2}}</div> {{/rollTotal() roll 2}} {{#rollTotal() roll 3}}<div class="sheet-template-row template-center">Difference: {{difference3}}</div> {{/rollTotal() roll 3}} {{#rollTotal() roll 4}}<div class="sheet-template-row template-center">Difference: {{difference4}}</div> {{/rollTotal() roll 4}} {{#rollTotal() roll 5}}<div class="sheet-template-row template-center">Difference: {{difference5}}</div> {{/rollTotal() roll 5}} {{#rollTotal() roll 6}}<div class="sheet-template-row template-center">Difference: {{difference6}}</div> {{/rollTotal() roll 6}} </div> {{/target}} Somehow in the course of copying your code I completely wrecked this part of the template, so I'll need to try again tomorrow. This is an interesting thought experiment though, thanks for sharing! Oh my goodness this code is completely filthy
1596364150

Edited 1596364205
GiGs
Pro
Sheet Author
API Scripter
That will be broken because the linebreaks in the button value break the rolltemplate. Combine all that onto a single line and it should be formatted correctly.
1596366333
GiGs
Pro
Sheet Author
API Scripter
There's a hack that allows use of the same number in two different places. It requires you to write it a little differently. <button class='button' type='roll' name='d100' value="&{template:mythic} [[ [[1d100]] - ?{Target Number?|50}]] {{character= @{character_name}}} {{target= [[?{Target Number?}]]}} {{raw_roll=$[[0]]}} {{difference=$[[1]]}}">1d100</button> Note the roll part near the start that is not inside {{ }} brackets. That means it will not be included in the rolltemplate. But the $[[0]] and $[[1]] later get the first and second inline rolls respectively.
1596426247

Edited 1596426522
Sammy Silver
Sheet Author
It can be made non-hacky by putting the "Target Number?" query in another inline roll, as in: <button class='button' type='roll' name='d100' value="&{template:mythic} [[ [[?{Target Number|50}]] - [[1d100]] ]] {{character= @{character_name}}} {{target= $[[0]]}} {{roll=$[[1]]}} {{difference=$[[2]]}}">1d100</button> Is the thing about $[[0]] getting inline rolls on the wiki? I didn't even see this there! This is amazing!
1596447842
GiGs
Pro
Sheet Author
API Scripter
I deliberately didnt do it that way, to keep down the number $[[0]] symbols. But if you prefer it that way, that's perfectly fine. I referred to it as hack because the whole thing is hack: the ability to reuse inline rolls like this is a recent discovery, most likely a result of a bug that we are exploiting. So there's no guarantee it will keep working for ever, but it works now :)
Yeah wtf when did this get discovered? This seems like a very good thing to have potentially.  GiGs said: I deliberately didnt do it that way, to keep down the number $[[0]] symbols. But if you prefer it that way, that's perfectly fine. I referred to it as hack because the whole thing is hack: the ability to reuse inline rolls like this is a recent discovery, most likely a result of a bug that we are exploiting. So there's no guarantee it will keep working for ever, but it works now :)
1596578105
GiGs
Pro
Sheet Author
API Scripter
Jake M. said: Yeah wtf when did this get discovered? This seems like a very good thing to have potentially.  Just a few weeks ago. It's really new.