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

Reusing rolls, [] pair matter and math seems to possible

Hi and sorry in advance for sheit formatting, being inconsistent with my past and present and this being a trick and investigation into reusing rolls results, but i wanted to share it somewhere and this felt like the correct place since the megathread about reusing rolls is now locked. So I started yesterday evening trying to do some weird stuff with boolean evaluations in roll20 and then I went on a tangent and tried to use the boolean expression with reusing rolls, this is what i have found and being a retelling of most of it today after having a nights rest. My first test failed with this comment : "Can't eval boolean operation, but $[[2]] is turned into normal text." Roll: $[[0.computed]] $[[1.computed]] $[[2]] [[{ 1d1+[[ [[1d10]] + [[2d6]] ]]}>3]] Result: And after trying a bit more and reading about Computed rolls and order independence in the reusing roll wikipage i tried again, and ended up with this comment: "Can access boolean if i try to access $[[3]]" Roll: $[[0.computed]] $[[1.computed]] $[[2.computed]] $[[3.computed]] [[{ 1d1+[[ [[1d10]] + [[2d6]] ]]}>3]] Result: With the following comment being: "What if i tried to not use .computed?" Roll: $[[3]] [[{ 1d1+[[ [[1d10]] + [[2d6]] ]]}>3]] Result: And the next comment in my notes being: "Okey so this works, can i add multiplication to it?" With a no as the result Roll: [[$[[3]]*2]] [[{ 1d1+[[ [[1d10]] + [[2d6]] ]]}>3]] Result: But not being content with that I started to brute force some changes to the roll and after some retries and just by sheer luck and stupidity added an extra pair of [] around the boolean evaluation. Roll: [[$[[3]]*2]] [[[{ 1d1+[[ [[1d10]] + [[2d6]] ]]}>3]]] Result roll: And this ended with a comment: Oh this works, does it work with attributes? Roll: [[$[[3]]*2+@{Orion|CritBon}]] [[[{ 1d1+[[ [[1d10]] + [[2d6]] ]]}>3]]] Result: And almost calling it here a new thought popped into my head: But what if I want to try to access the internal [[1d10]] and [[2d6]] rolls?  Roll: [[$[[3]]*2]] $[[2]] $[[1]] $[[0]] [[[{ 1d1+[[ [[1d10]] + [[2d6]] ]]}>3]]] Without computed: And the next comment from me being: It breaks apart… so how do i fix this?  After trying a couple of times with adding more [] pairs I found that adding .computed was the only way to fix it for me (there might be other ways to fix this).  Roll: [[$[[3]]*4]] $[[2.computed]] $[[1.computed]] $[[0.computed]] [[[{ 1d1+[[ [[1d10]] + [[2d6]] ]]}>3]]] Result: After this I found myself commenting this: So can this do more?  Kinda yeah, me trying to reuse the computed value twice resulted in only in the first $[[2]] being rerolled Roll:[[$[[2]]d2]] [[$[[2]]d1+1 ]] [[[ [[1d10]] + [[2d6]] ]]] And then building on that information i tried some other stuff which are not documented at all… but what is documentation is this comment and the three rolls below: Oh it can build ladders :O  [[1d$[[2]] + 10 +9 ]] [[1d$[[1]] + 5 + 6 ]] [[1d$[[0]] + 1 + 2 ]] [[[ [[1d10]] + [[2d6]] ]]] [[1d$[[2]] + 10 +9 ]] [[1d$[[1]] + 5 + 6 ]] [[[1d$[[0]] + 1 + 2 ]]] [[[ [[1d10]] + [[2d6]] ]]] [[1d$[[2]] + 10 +9 ]] [[[1d$[[1]] + 5 + 6 ]]] [[[1d$[[0]] + 1 + 2 ]]] [[[ [[1d10]] + [[2d6]] ]]] So i checked them out this morning and noted that they contain different amount of [] paris and after rerunning them this is what happened So… first row in the pictures show that $[[1]] value is the result of [[1d$[[0]] + 1 + 2 ]] and are not used in the next roll and $[[2]] is using the 1d10 result after hovering over the $[[2]] complete roll. Second row has an added pair of [] around the $[[0]] roll and now makes the $[[1]] use the result form [[[1d$[[0]] + 1 + 2 ]]] for a new roll that $[[2]] tries to use and for some reason [[2d6]] result is in plain text. And the last row has another pair of [] around the $[[1]] and $[[2]] now uses the $[[1]] result and rolls, but 2d6 roll is still plain text. So the amount of [] seems to matter here. But why is the 2d6 turned into plain text then? What I could find before writing this is that depending on what $[[]] is accessing it changes text print. If $[[0]] (1d10) is accessed then the roll of 2d6 is turned into plain text [[$[[0]]d1 ]] [[[ [[1d10]] + [[2d6]] ]]] If $[[1]] (2d6) is accessed then the roll of 1d10 is turned into plain text [[$[[1]]d1 ]] [[[ [[1d10]] + [[2d6]] ]]] f $[[2]] (sum of 2d6 + 1d10) is accessed then it works and an extra pair or [] is printed [[$[[2]]d1 ]] [[[ [[1d10]] + [[2d6]] ]]] But I’m still not any smarter, thanks to not understanding what i happening under the hood in roll20 and wanting to do other stuff I instead tried to use .computed as a value in a calculation like since that was nagging me that i didn’t try it yesterday or at least didn’t keep any notes. So what happens with .computed… yeah it does not work [[$[[0.computed]]d1 + 10 +9 ]] [[[ [[1d10]] + [[2d6]] ]]]  Everything except $[[0.computed]] is now plain text, but the total of 1d10 and 2d6 are calculated. And yes i tried to just change the 0 to a 1 and 2 and same stuff just using the other values. Also stuff breaks if the order is changed :(. So the roll below works. [[$[[2]]d1 + 10 +9 ]] [[$[[0]]d1 + 100 ]] [[[ [[1d10]] + [[2d6]] ]]] But moving the $[[]] access to the end of the string doesn’t work, so order is important here. [[[ [[1d10]] + [[2d6]] ]]] [[$[[2]]d1 + 10 +9 ]] [[$[[0]]d1 + 100 ]] TLDR: The amount of [] matter to reuse a computed roll in another roll and $[[]] value seems to be only able to reuse once :(.
1644760417
GiGs
Pro
Sheet Author
API Scripter
You're not showing the fiull expressions (some of your examples list $[[2]] as the starting point, for exampe, and there must be at least 3 inline rolls before that) so it's hard to properly follow everything. However, you are suggesting some things I wasn't aware of - I was under the impression you couldn't perform any  calculation with a reused roll like $[[0]], apart from the limited .computed option. Can you create a listing of your findings, showing the things you can do, and under that a listing of things you can't do?
This is probably going to be in rambles again but I gave it another hour and yeah, see below. Now I'm going to put this on the bench for a bit and hope that someone else explores this more and might crack the code for this and prove some of my restrictions and problems wrong . Restrictions and problems: Order dependent... It is only possible to reuse a rolls value if the next roll that wants to use it is before the one it references. So [[[$[[1]]%2]]] [[[$[[0]]%5]]] [[[1d10]]] works because 1 is before 0 and 0 before original roll but [[[$[[0]]%5]]] [[[$[[1]]%2]]] [[[1d10]]] will only show $[[1]] value but do nothing with it . Roll result can only be reused once for a new roll calculation. This reuse roll [[$[[0]]%2]] [[[$[[0]]%5]]] [[[1d10]]] will only work for the first reference of $[[0]] To continue using a previous reused roll the one after needs to have an extra pair of [] around it. So this works [[$[[1]]%2]] [[[$[[0]] ]]] [[[1d10]]] whilst [[$[[1]]%2]] [[$[[0]] ]] [[[1d10]]] does not To add previous rolls total value to a new roll there must be something following the $[[]] index and not only a ] so a space or a plus something that does not look like this [[1d20*$[[1 ]]] ] [[[{1d1+$[[0]]}&gt;3]]] [[[1d10]]]&nbsp; or [[1d20*$[[1 ]]]] [[[{1d1+$[[0]]}&gt;3]]] [[[1d10]]] You can make it look like there was no roll only plain text. Yeah this is weird and something I wrote about in my first post but exampel with template here &amp;{template:default} {{name=Initiative}} {{roll=$[[1]]}}&nbsp; [[[$[[0]]%5]]] [[[1d20+4]]] will display the result index as plain text but if the outer pair of [] from [[[$[[0]]%5]]] then it displays and if you just want to it could be placed directly into the roll template also with or without the extra [] around [[[$[[0]]%5]]] Accessing internal roll breaks stuff if .computed isn't used like from my first post [[$[[3]]*2]] $[[2]] $[[1]] $[[0]] [[[{ 1d1+[[ [[1d10]] + [[2d6]] ]]}&gt;3]]] does not work but [[$[[3]]*4]] $[[2.computed]] $[[1.computed]] $[[0.computed]] [[[{ 1d1+[[ [[1d10]] + [[2d6]] ]]}&gt;3]]] works if you just want to check the internal rolls of [[[{ 1d1+[[ [[1d10]] + [[2d6]] ]]}&gt;3]]] and only use the boolean result later on . Index ($[[]]) jumps around a lot for some reason. What seems to work: addition, modulus, division work (only tried on of them at a time) ceil and floor work Roll templates work &amp;{tracker} kh work, which probably means keep lowest also works internal calculations work [[{1d1, [[$[[0]]d1+829]]d1}kh1]] [[[1d10]]] Result can be reused to roll more dies! [[{1d1, $[[0]]d1}kh1]] [[[1d10]]] Can display rolls results as previous examples of reusing rolls have shown on the wiki. Results of in-between rolls can be added together. Example [[$[[2]]+$[[0]] ]] [[[1d20]]] [[[$[[1]]+1 ]]] [[[1d10]]] here i use [[[1d10]]] to add 1 to it with [[[$[[1]]+1 ]]] (for some reason indexes are not what i expected) and then roll a new value [[[1d20]]] and then add them together with [[$[[2]]+$[[0]] ]] (again indexes). NOTE : I think it's possible to use [[[$[[1]]+1 ]]] as a new roll without needing the +1 in it so just [[[$[[1]] ]]] for the [[$[[2]]+$[[0]] ]] You can make it look like there was no roll only plain text (see problems) Channing rolls (don't know what to call this), mentioned in the problem bit for To continue using a previous reused roll. Link to my google docs notes for my hour of testing <a href="https://docs.google.com/document/d/1RHbZJowOz7oX-gHbgH9mxS0X9872qxp5pSqdG5l0_GU/edit?usp=sharing" rel="nofollow">https://docs.google.com/document/d/1RHbZJowOz7oX-gHbgH9mxS0X9872qxp5pSqdG5l0_GU/edit?usp=sharing</a> I hope this answers some questions and provides help with further research/findings about reusing rolls since I'm putting this on the bench for a while and just returning being a normal free roll20 user that will just watch stuff happen and complain about how bad some character sheet css style choices are and implementation without providing help to fix those problems. Something that just popped into my head is that this is very close to functional programming with the limitation of only being able to use a variable once. Update since I'm migrating my google drive to another account here are the notes part 1. This is sadly all order dependent to reuse the result of another roll, is what I’m finding but prove me wrong please! Booleans boolean expression work&nbsp; [[{1d1+$[[0]]}&gt;3]] [[[1d10]]] boolean expression can be used to calculate stuff [[20*$[[1]] ]] [[[{1d1+$[[0]]}&gt;3]]] [[[1d10]]] Reuse boolean to fake crit or other conditional stuff Can be used if another roll is done in the same [[]] group. [[1d20*$[[1]] ]] [[[{1d1+$[[0]]}&gt;3]]] [[[1d10]]] Restriction IMPORTANT There must be something following the $[[]] call either a space or something else not a ] directly after. [[1d20*$[[1 ]]] ] [[[{1d1+$[[0]]}&gt;3]]] [[[1d10]]] results in [[1d20*$[[1 ]]]] [[[{1d1+$[[0]]}&gt;3]]] [[[1d10]]] results in Problem For some reason the index is moved…. So now everything starts with a $[[1]] [[[({1d1+$[[1]]}&gt;3)*[[1d20+22]]]]] [[[1d10]]] works but is printed in plain text so can’t see the rolls content [[[[[[1d20+22]]+({1d1+$[[1]]}&gt;3)]]]] [[[1d10]]] also works but for some reason the&nbsp; [[[[[[1d20+22]]+({1d1+$[[1]]}&gt;3)]]]] [[[1d10]]] gives a hover tooltip but can’t see what it rolled… Trying to find my rolls $[[2.computed]] [[[({1d1+$[[1]]}&gt;3)*[[1d20+22]]]]] [[[1d10]]] with computed i can now extract the roll Index problem… but found my rolls! $[[2.computed]] $[[0.computed]] [[[[({1d1+$[[1]]}&gt;3)*[[1d20+22]]]]]] [[[1d10]]] inline roll is now counted as $[[0]] don’t know why but I can now expose the full thing Modulus calc Even modular calculations work… well this is getting somewhere [[[[({1d1+$[[1]]}&gt;3)%[[1d20+22]]]]]] [[[1d10]]] Division jup i can [[[[({1d1+$[[1]]}&gt;3)/[[1d20+22]]]]]] [[[1d10]]] Floor and ceil [[[[floor(({1d1+$[[1]]}&gt;3)/[[1d20+22]])]]]] [[[1d10]]] [[[[ceil(({1d1+$[[1]]}&gt;3)/[[1d20+22]])]]]] [[[1d10]]] Do i need extra []? Back to basics&nbsp;and it works [[$[[0]]%5]] [[[1d10]]]&nbsp; but still need those extra [] for the first roll calc&nbsp; [[$[[0]]%5]] [[1d10]] &nbsp; Yes I do… Can’t reuse same roll results twice And as previous written can’t use same roll twice [[$[[0]]%2]] [[$[[0]]%5]] [[[1d10]]] &nbsp; Channing reuses [[$[[1]]%2]] [[$[[0]]%5]] [[[1d10]]] &nbsp;fails but adding [] around&nbsp; [[$[[0]]%5]&nbsp;now works [[$[[1]]%2]] [[[$[[0]]%5]]] [[[1d10]]] Faking a crit/condition I can given a crit confirm if the result o hits&nbsp; [[$[[1]]d10]] [[[{1d0+$[[0]]}&gt;3)]]] [[[1d10]]] Now the question is can I display $[[1]] roll it without breaking stuff? Yes I can and it does not interrupt the other calculations [[$[[1]]d10]] [[[{1d0+$[[0]]}&gt;3)]]] [[[1d10]]] $[[2]]
1644780623

Edited 1644828022
GiGs
Pro
Sheet Author
API Scripter
You've been very thorough exploring this. That's a lot of fantastic research to build on and replicate.
1644793788
Andrew R.
Pro
Sheet Author
Nice work! Thanks for all your effort.&nbsp;
Would be awesome if someone found out a way to use a roll twice or use internal rolls with out breaking stuff, since I was not able to find it :( Update since I'm migrating my google drive to another account here are the notes part 2 ( link to first part ). Trying calculate on the right side But what happens if you try to use that $[[2]] in a new calculation? I guess stuff breaks. No it does not :O but i can’t manipulate it at all [[$[[1]]d10]] [[[{1d0+$[[0]]}&gt;3)]]] [[[1d10]]] [[[$[[2]]+1]]] [[$[[1]]d10]] [[[{1d0+$[[0]]}&gt;3)]]] [[[1d10]]] [[[{$[[2]]}+1]]] And if i want to I can even use $[[1]] or $[[0]] but they can’t be manipulated if they come after the roll that made them only before. Keep highest [[{1d1+$[[0]]}kh1]] [[[1d10]]] [[{1d1, $[[0]]d1}kh1]] [[[1d10]]] I can even turn it into a die if a wanted to :D Why not do an internal roll calc with the reuse roll? [[{1d1, [[$[[0]]d1+829]]d1}kh1]] [[[1d10]]] This should mean that keep lowest also works skipping that test Tracker Test with the tracker then [[ $[[0]]d1 &amp;{tracker} ]] [[[1d10]]] and it works :O Even without needing to roll a die [[$[[0]] &amp;{tracker}]] [[[1d10]]] Roll template So does it work with the simple roll template?? Yes. &amp;{template:default} {{name=Initiative}} {{roll=[[$[[1]]+1]]}}&nbsp; [[[$[[0]]%5]]] [[[1d20+4]]] And if you just want to have it as normal text&nbsp; &amp;{template:default} {{name=Initiative}} {{roll=$[[1]]}}&nbsp; [[[$[[0]]%5]]] [[[1d20+4]]] And if not remove the extra pair of [] around the $[[0]] roll &amp;{template:default} {{name=Initiative}} {{roll=$[[1]]}}&nbsp; [[$[[0]]%5]] [[[1d20+4]]] You can even move the new roll into the template and skip calling $[[1]] &amp;{template:default} {{name=Initiative}} {{roll=[[$[[0]]%5]]}} &nbsp; [[[1d20+4]]] Looks a bit weird if an extra pair of [] are added &amp;{template:default} {{name=Initiative}} {{roll=[[[$[[0]]%5]]]}} &nbsp; [[[1d20+4]]]
I've been compiling data around this for a while (more coming soon) but haven't found anyway to use a roll result in more than one inline roll. From what I've been able to gather it may currently be impossible to use a specific result twice.
Damn that doesn't sound that good and I hope that I didn't steal the first post regarding, if it is the first post regarding thisssubject of reusing rolls. Also if there isn't a way to reuse a roll more then once then maybe clever use of macro button calling might be the solution for me creating a easy/single attack macro with a query inside of it.
1644862388
Andreas J.
Forum Champion
Sheet Author
Translator
I linked the thread on the wiki page listing most of the stuff: <a href="https://wiki.roll20.net/Reusing_Rolls" rel="nofollow">https://wiki.roll20.net/Reusing_Rolls</a> If you come across with new stuff, adding a link there will make it easier to find in the future
Nygaard said: Damn that doesn't sound that good and I hope that I didn't steal the first post regarding, if it is the first post regarding thisssubject of reusing rolls. Also if there isn't a way to reuse a roll more then once then maybe clever use of macro button calling might be the solution for me creating a easy/single attack macro with a query inside of it. I needed the push to actually get it done. I've now posted my Macro curiosities thread. What you been seeing here is accessing the plain numeric result of a roll. After that it's just a number and can be used anywhere. Including earlier than intended. So for the specifics of what does and doesn't work is limited to where a plain number would or wouldn't work. But also that the plain number is only available once.
So whilst doing some macro fixing in an active campaign i found another restriction to this trick :/ Raw boolean evaluation checks do not work and do not print anything in chat and my test below that do not work [[{$[[0]]+1}&gt;10]] [[[1d20]]] [[{$[[0]]}&gt;10]] [[[1d20]]] [[1+{$[[0]]}&gt;10]] [[[1d20]]] [[1d0+{$[[0]]}&gt;10]] [[[1d20]]] But it does work if there is another value roll inside the boolean check [[{$[[0]]+1d0}&gt;10]] [[[1d20]]] [[{1d0+$[[0]]}&gt;10]] [[[1d20]]] and prints Also hence forth i will be using the term used on the wiki Target Number (Successes) instead of using boolean evaluations, if post anything more regarding this whilst addressing target number checks.
That's not actually a restriction of using an early roll reference but a restriction of the parser in general. The parser doesn't support single sub-roll group target number expressions without a roll expression, and using references in this way replaces them with a plaintext number so it gets treated as it's you had typed in the number rather than being a roll result. You can replicate the bug without using a roll reference as thus [[{[[10]]}&gt;10]] Your first non-working example can be made to work, by adding an extra sub-roll, as [[{$[[0]]+1,0}&gt;10]] [[[1d20]]]