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

reverse text to reuse a roll in 5e npc action

I was driving myself insane trying to reuse a roll for a dex saving throw half damage calculation. Then I thought just reorder the text! original; The kraken magically creates three bolts of lightning, each of which can strike a target the kraken can see within 120 feet of it. A target must make a DC 23 Dexterity saving throw, taking 22 (4d10) lightning damage on a failed save, or half as much damage on a successful one. changed it to; The kraken magically creates three bolts of lightning, each of which can strike a target the kraken can see within 120 feet of it. A target must make a  ``DC 23`` Dexterity saving throw, taking half damage ([[floor(0.5*[[4d10]])]]) on a success, or $[[0]] lightning damage on a failed save.  happy days
thats a nice catch! It can be surely used in lot more cases... 
1607274347
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That's a good candidate for a  Stupid Trick .
that didn't work quite as i expected for multiple rolls
1607311062

Edited 1607311915
Oosh
Sheet Author
API Scripter
The indexing increases with each pair of inline roll brackets. So for this: {{roll1: [[floor(0.5*[[3d6]])]] damage on a successful save, $[[0]] on a fail. roll2: [[floor(0.5*[[3d6]])]] damage on a successful save, $[[2]] on a fail.}} You need to skip $[[1]] for the second roll, as it's the outer brackets from roll1. $[[2]] is the inner brackets from roll 2, $[[3]] will be the outer brackets from roll 2. Once you start nesting and throwing lots of rolls into the same message, the indexing gets out of whack pretty quickly and becomes (so far, at least) trial and error. I can't remember if this made it into Stupid Tricks or not, but dealing with loads of rolls and trying to reuse them by index is difficult - generally best to find another solution when the rolls get heavy, like: roll1: [[floor(0.5*[[3d6]])]] damage on a success, $[[0]] on a fail [Additional Attack](~extraAttack) where extraAttack is an ability that outputs the same thing on another chat line. &{template:npcdmg} is an attractive option for this, as it attaches to the bottom of the other npc templates. It depends on how complicated the rolls are, and whether or not you're likely to ever edit the ability (adding a roll anywhere on the template will wreck your indexing). And if you go down this path, definitely invest in either Stylus (for private rolls) or style injection (if the players can see them) for the button links, the giant pink default ones look horrendous in the tiny npcdmg template. Yet another option is doing the math outside the template properties This allows you to put things in whatever order you want. So putting this into the description field for example: }} [[floor(0.5*[[3d6]])]] [[floor(0.5*[[3d6]])]] [[floor(0.5*[[3d6]])]] [[floor(0.5*[[3d6]])]] [[floor(0.5*[[3d6]])]] {{description=$[[0]] $[[1]] $[[2]] $[[3]] $[[4]] $[[5]] $[[6]] $[[7]] $[[8]] $[[9]] Should allow you to hover over each result and make sure they're in the right order. Generally they behave OK with rolls nested no more than 2 deep. Once you get to 5-10 rolls, each with [[ [[ [[ 3 layers ]] ]] ]] of nesting, the order becomes completely scattered after the first 1 or 2 rolls. Somewhere before the 10 mark, it'll start rolling all the inner brackets for a heap of rolls, before returning back up the line to fill in the outer brackets (it's supposed to work inside => outside for each discrete collection of rolls).
IDK I just didn't expect this. just sharing - I know how to fix it.  I just found it interesting is all