Difference between revisions of "Reusing Rolls"
From Roll20 Wiki
Andreas J. (Talk | contribs) (→See Also: more links) |
Andreas J. (Talk | contribs) m |
||
Line 61: | Line 61: | ||
Now we can create macros that do our math for us. Total the damage from a complicated attack (or one that hit several times), display the parts of a roll so that what went into that roll is visible without needing to hover over it. And I'm sure folks will come up with quite a few other ideas that I haven't even thought of. | Now we can create macros that do our math for us. Total the damage from a complicated attack (or one that hit several times), display the parts of a roll so that what went into that roll is visible without needing to hover over it. And I'm sure folks will come up with quite a few other ideas that I haven't even thought of. | ||
− | === | + | ===Reordering Rows=== |
− | * https://app.roll20.net/forum/permalink/8761813/ | + | * https://app.roll20.net/forum/permalink/8761813/ by GiGs |
Develops further some ideas based on Scott's original '''Reuse Rolls''' stupid trick. | Develops further some ideas based on Scott's original '''Reuse Rolls''' stupid trick. |
Revision as of 18:53, 14 January 2021
In early 2020, it was noticed that you could re-use roll in macros without using API. This Page lists some of the top posts and comments that figures out uses for it.
- Reusing Rolls - Megathread
- Re-use die rolls in macros, treated as numbers rather than just text - Suggestion Forums
- Original discovery by Syneran
Contents |
Collected tricks
Scott C's Trick
Stupid Roll20 Tricks (and some clever ones) - forum link
- Disclaimer: This trick takes advantage of emergent behavior that may not be intended and may be patched*
I can't take credit for this trick. Syneran discovered the capability. But, long story short, it is actually possible to reuse rolls with some small caveats. Here's a summary of the info discovered in the linked forum thread:
The chat accepts the inline roll indexing used in the API (and apparently the roll parser itself), so you can do:
[[ [[1d20]] + [[1d6]] + [[6]] ]] = $[[0]] + $[[1]] + $[[2]]
And get an output that would read something like this:
(image todo)
The limited part is you can't use those indexed rolls inside other rolls. So for instance, you can't reverse the above output like this:
[[1d20]] + [[1d6]] + [[6]] = [[$[[0]] + $[[1]] + $[[2]] ]]
Using the indexes appears to break any containing inline rolls, like so:
Additionally, the indexing is line specific, so this also doesn't work:
[[1d20]] + [[1d6]] + [[6]] [[$[[0]] + $[[1]] + $[[2]] ]]
These are pretty big limitations if you're just typing rolls into chat, but we can circumvent it through good use of roll templates. For instance, we could hid the actual roll in between roll template fields, and then present them in whatever order we wanted:
&{template:default} [[ [[1d20]] + [[1d6]] + [[6]] ]] {{name=My Attack}} {{$[[0]] + $[[1]] + $[[2]]==$[[3]]}}
which would give us this output:
For those with API access, the API sees this message with the proper indexes showing, so any API that handles rolls should react to these indexed rolls just like they were regular rolls.
What's it allow us to do though?
There's several new things this allows the community to do that were previously locked behind access to the API.
Character Sheets
When making custom character sheets (or sheets for the repo), one of the big hurdles has been accomodating systems that require you to know multiple things about a complex roll. Something like say the success of a roll in relation to a target number, as well as the value of the roll itself. Or if a given number on a die counts as 0 (or some other number).
General Macro Creation
Now we can create macros that do our math for us. Total the damage from a complicated attack (or one that hit several times), display the parts of a roll so that what went into that roll is visible without needing to hover over it. And I'm sure folks will come up with quite a few other ideas that I haven't even thought of.
Reordering Rows
Develops further some ideas based on Scott's original Reuse Rolls stupid trick.
Rolltemplate Helper functions
by GiGs
Note: This is specifically for character sheet designers, but it's an implementation of an earlier trick from this thread that is only documented here.
Here's another nifty and counter-intuitive thing about Resuing rolls:
When using them in a rolltemplate, you can use them with logic functions, like rollGreater()
.
For instance:
&{template:custom} [[ [[1d100]] - ?{Target Number?|50}]] {{target=[[?{Target Number?}]]}} {{raw_roll=$[[0]]}} {{difference=$[[1]]}}
and a rolltemplate
<rolltemplate class="sheet-rolltemplate-custom"> <div class="sheet-content"> <div class="sheet-key">Target</div> <div class="sheet-value">{{target}}</div> <div class="sheet-key">Raw Roll</div> <div class="sheet-value">{{raw_roll}} {{#rollGreater() raw_roll target}} (above Target) {{/rollGreater() raw_roll target}}</div> <div class="sheet-key">Difference</div> <div class="sheet-value">{{difference}}</div> </div> </rolltemplate>
This will show the text (above Target) for raw_rolls
that roll above the target - even though row_roll
is one of these weird pseudo-inline rolls.
This makes these quantities even more useful for character sheet design.
Two Unique Roll Results
by Persephone
I was trying to find a way to roll 2d8, getting both results separately without getting the same result twice, when I remembered this trick. Turns out it works for inline rolls that are nested inside each other.
[[1d8r[[1d8]]]], $[[0]]
The outer nesting is treated as the last one in the line, so $[[0]]
gives you the result of the first inline roll in the deepest layer of the roll while $[[1]]
gives you the same result as the complete roll. If the nested 1d8 results in a 4, the outer roll becomes 1d8r4 so it rerolls any results of 4. The $[[0]]
will show an output of 4 and the inline roll will have a result of any number between 1 and 8, except for 4.
I haven't yet tested multiple nested layers or multiple inline rolls within the main roll, but I suspect preventing more than 2 rolls from matching would get quite complex, if at all possible.
(Comment: GiGs would rather call this something like Multiple Rolls - Each Unique)
Reusing Rolls (advanced)
by Gibli
I always wanted to be able to re-use a Roll in a subsidiary Roll, but as stated by Scott C. here, it breaks the inline Roll.
So, here I thought of a workaround : why not call an Ability depending of the result of my Roll through a button ?
It might ask a lot of work most of the time, but in some cases it's pretty simple and quick to put in place.
However, it didn't work through my first attempt.
Here is an example : I have a trap which when you fall in it make you hit by 1d4 spikes, each spike doing 1d4+2 damages.
Then, I wanna have something like this :
[[1d4]] [[ $[[0]]d4 + 2*$[[0]] ]]
Of course, it doesn't work as is.
So, I put them in different abilities with a call through a button like this : Trap :
&{template:default} {{name=Trap}} {{Pikes=[[1d4]]}} {{Damages=[Throw](~PikesDamages$[[0]])}}
PikesDamages1 :
&{template:default} {{name=Pikes Damages}} {{Damages=[[1d4+2]]}}
PikesDamages2 :
&{template:default} {{name=Pikes Damages}} {{Damages=[[2d4+4]]}}
PikesDamages3 :
&{template:default} {{name=Pikes Damages}} {{Damages=[[3d4+6]]}}
PikesDamages4 :
&{template:default} {{name=Pikes Damages}} {{Damages=[[4d4+8]]}}
The trick is that the previous Roll shall be replace by 1, 2, 3 or 4 in the name of my Ability, making the button call the correct one.
Yet, as I said, my first try didn't work for a pretty simple reason :
When you pu the caller to the previous roll $[[0]]
in the parenthesis for the name of the ability, it is replaced by a text such like this :
[Throw](~PikesDamages Rolling 1d4 = (1)'>1)
This text is specifically for a call to a Roll of 1d4 which resulted in a 1.
So here is the workaround :
Rather than calling the abilities PikesDamages1
to PikesDamages4
, I called them PikesDamages Rolling 1d4 = (1)'>1
to PikesDamages Rolling 1d4 = (4)'>4
, and it works perfectly !
For you to have spaces in the name of an Ability, you can simply write the name you want anywhere and then simply copy/past it.
Spaces are replaced by dashes only while you type them, the copy/past bypass this.
Note(Gibli): I haven't found why, but it seems that the button need to be put at the end of the RollTemplate. He might not appear in the chat otherwise. And be careful if your RollTemplate has many intricate Inline Rolls, try to always put the one you want to Reuse first, and your button last in the RollTemplate.
See Also
- Complete Guide to Macros & Rolls
- q Text Chat - where the roll results appear, & info on the common chat commands
- Dice Reference - Comprehensive list of how the Roll20 dice-rolling syntax works, and list the features available
- Macros - How to create macros, and other info on how the Roll20 qText Chat works, like referencing stats on character sheets, roll queries, nesting macros & initiative
- Reusing Rolls
- Roll Templates - a method of formatting roll results in the chat, with some extra functions
- API(Pro Only) - API commands can be used in the qText Chat
- Building Character Sheets