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 .
×
The developers are currently investigating an issue with logging in + accessing the VTT.
Create a free account

Rolls in Roll Templates

1476256425
Falcon
Pro
Sheet Author
I know from using Roll templates that a inline roll is stored somewhere because you can use it several times in helper functions.  I would like to take an character ability and subtract it from the roll but also display the roll.  I can't seem to find a way because you can't do inline functions in the roll template code in the character sheet. Is there anyway to put that inline roll into a variable and use it in a macro?  (basically storing the roll for macro use). For instance: [[@{STR} - {{roll}}]]  would give the difference if successful.  The {{roll}} is what is rolled in the roll template macro.  if this is impossible currently that is fine, I am hoping there is a way that I just don't know.
1476258196
Tetsuo
Forum Champion
I know that in the PowerCards api script , you can call the result of a roll several times, and could potentially do something like: Result:| [[@{str} - [[ [$Roll] 1d6]] Original Roll:| [^Roll] Which would roll a d6, subtract it from your strength and display the result, then display the result of the original roll. The only issue with this is that you can't do any sort of math functions with the [^Roll] display. Other than that, I'm not too sure. May be a good place to start, at least.
1476261910
Finderski
Plus
Sheet Author
Compendium Curator
Unfortunately, you can't do "real-time" math in roll templates—they just display what is passed into them. If the simpleness of the math isn't something you're overly concerned about, you can always pass in the different elements individually and let people do their own subtraction. Something like {{str=@{str}}} {{roll=[[1d6]]}}. You could even multiply the roll by -1 so it shows as a negative number (reminding people it should be subtracted).
1476262299
Tetsuo
Forum Champion
If you wanted to store a die roll into a callable attribute, one idea is to use the chatsetatt api script to roll a die, and set the result as an attribute on a sheet, then call the attribute via your macros.. 
1476286491
Falcon
Pro
Sheet Author
Thank you.  Yeah, I thought about each of those concepts.  No issues - we will just have to manually do the math!  Ha.  Seriously though, the dice result that is captured for the helper functions are stored somewhere - I just wish we could re-use that information within the same roll template and do simple math.