Reusing Rolls
From Roll20 Wiki
Page Updated: 2024-03-18 |
- Reusing Rolls - Megathread(Forum)
- Re-use die rolls in macros, treated as numbers rather than just text(Forum) - Suggestion Forums
Macro Creation
- Complete Guide to Macros & Rolls
- q Text Chat
- Dice Reference
- Order of Operations
- Macros
- Roll Query
- Initiative
- Reusing Rolls
- Token Reference
- Character Reference
- Roll Templates
- Roll Table
Advanced
- Formatting
- HTML Replacement
- Chat Menus
- Hidden Rolls
- Advanced Macro Tips
- API Commands
- Char Sheet Creation
- External tools
Misc.
- Original discovery(Forum) by Syneran
Collected Tricks
Scott C's Original Trick
Stupid Roll20 Tricks (and some clever ones)(Forum) - Initial Trick writeup - Scott C
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:
And get an output that would read like this:
The limited part is you can't use those indexed rolls inside other rolls. So for instance, you cannot reverse the above output in the following way:
Using the indexes appears to break any containing inline rolls, like so:
Additionally, the indexing is line specific, so this also doesn't work:
However, a new line can be achieved by using %NEWLINE%
:
These are pretty big limitations if you're just typing rolls into q Text Chat, but we can circumvent it through good use of roll templates. For instance, we could hide the actual roll in between roll template fields, and then present them in whatever order we wanted:
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.
While you can't nest indexed rolls, you can nest the roll it's referencing, e.g:
In this case, index 0
will find the result of 1d20
, index 1
will include the str_mod
, and index 2
will subtract the str_mod
from the previous value and add the 6.
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 Mods(API).
Character Sheets
When making custom character sheets (or sheets for the repo), one of the big hurdles has been accommodating 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 trick.
one feature lots of people have asked for over the years, is to be able to roll a set of ability scores, and show the total at the same time. With this new trick, you can do that. For example:
This will result in:
The problem here is it shows the Total first. I haven't found a way to use the $[[ ]]
syntax to access a roll that others are nested inside, like Total here? Has anyone else figured out how to do that?
My trick is: there is way to reorder the rows within the template, if you don't mind using numbers as the row titles:
This will result in:
It turns out that if your default template row name (the part before the =
) is just a number, it gets sorted before any text entries, and in numerical ascending order.
If you want text labels, you put them after the =
, like so:
So there you go, another implementation of the new 'feature' (or is it a bug), and another undocumentated feature (or is it a bug?) of Roll Templates.
Note: negative numbers are sorted just like text, they don't change position. This trick works only for numbers 0 and higher. They don't have to be consecutive. It also doesnt work for inline rolls.
Rolltemplate Helper functions
by GiGs
- link(Forum)
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 Reusing rolls:
When using them in a rolltemplate, you can use them with logic functions, like rollGreater()
.
For instance:
and a 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
- link(Forum)
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)
example(Forum) by Gibli
I always wanted to be able to re-use a Roll in a subsidiary Roll, but as stated by Scott C. here(Forum), 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, like making a Chat Menu ?
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.
What didn't work |
Initial attempt:
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(Of course, it doesn't work as is.):
This text is specifically for a call to a Roll of 1d4 which resulted in a 1. 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. |
After some testing, saving Trap
as a character abilities with a roll button for the damage:
Trap :
Then save these 4 with exactly these names, as more character abilities:
Note(Gibli): I haven't found why, but it seems that the button need to be put at the end of the rolltemplate, it 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.
Computed rolls and order independence
With the addition of computed rolls comes new syntax to reference those rolls.
So if you have a roll $[[0]]
you can access the computed roll based on it via $[[0.computed]]
additionally all rolls have a computed roll that defaults to the original roll. You can even use the .computed
version without requiring a Roll Template at all.
Referencing a roll in this way also doesn't interfere with nested rolls like a standard reference would.
So while this breaks:
$[[0]] plus $[[1]] equals [[ [[1d10]] + [[2d6]] ]]
Using the .computed
version allows it to work
$[[0.computed]] plus $[[1.computed]] equals [[ [[1d10]] + [[2d6]] ]]
This could also be used when Overwriting template fields in macros. Since the fields you overwrite have to be before the ones that do the conditional overwriting you wouldn't have previously been able to reference any of the rolls used in determining the decision but with this you can
Reusing rolls, [] pair matter and math
Long thread with many tricks and insights
Macro curiosities, or how to overcomplicate everything
In the forum thread Macro curiosities, or how to overcomplicate everything by RainbowEncoder, RainbowEncoder shows a way to duplicate the result of a roll and to reuse it multiple times for further rolls or calculation shown in the post about Improved roll index manipulation and Duplicating a roll result for further calculations.
Reusing Rolls to get additional crit damage
- trick by Spencer
&{template:default} {{name=Crit}} {{2= Damage : [[ [[1d6+5]]+[[floor(( $[[1]]/50)d6)]] ]]}} {{1=Check : [[ [[1d20+5]] ]]}}
Sheets using this trick
- Barbaric! "reuse roll" trick is used for determining if a
2d6
roll is either a2
or12
, which in the system are crit success and fumble. • by Andreas J.
See Also
- Inline Rolls
- 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 q Text Chat works, like referencing stats on character sheets, roll queries, nesting macros & initiative
- 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