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

1644754207

Edited 1644754357
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?
1644771755

Edited 1647111573
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.
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;
1644818534

Edited 1644818755
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 :(
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.
1644855805

Edited 1644855931
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.
1647110723

Edited 1647111795
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.
1647112840

Edited 1647113517
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]]]