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 die roll more than once.

Hi, From the character sheet, when you press a button, you can generate a roll (for example  [[1d100]] ) and pass that to a template for display. What I would like to do is use the value of that roll to calculate a second number. I don't want to reroll it obviously. Is there some way to refer to that roll? Can I give it a variable name and refer to that?  Can I save the value in a temp attribute and then retrieve it?  I'm fine with any solution. Here's a simplified example of the button call: <button name="roll_S" type="roll" value="&{template:custom} {{description=Roll:  [[1d100]]   Calculated:  [[ THE_ORIGINAL_ROLL + 1 ]] }}"> Thanks in advance for any help.
1514077802
vÍnce
Pro
Sheet Author
Not without using an API script.  Once a macro is executed, roll20 and the quantum roller take over to post the results.  I believe the  Powercards API script can do this (I think you can use the $ID feature of the script)
Ok thanks.  I'll try experimenting with Powercards then.
FYI.  I tried Powercards and although you can output the same die roll multiple times you can't actually do any math on them.  So I've gone the API script route instead and that has provided me all the flexibility I needed. 
1514739010

Edited 1514739033
vÍnce
Pro
Sheet Author
Eddie X. said: FYI.  I tried Powercards and although you can output the same die roll multiple times you can't actually do any math on them.  So I've gone the API script route instead and that has provided me all the flexibility I needed.  Oh, I wasn't aware you couldn't perform calculations with the stored roll's value in other rolls.  ;-(  Maybe a request to  Sky , Powercards author is in order...? Glad you got it figured out. This particular question is often asked on the forums.  Care to share how you solved the problem for yourself?  
Sure.  So my problem was I wanted to perform additional calculations based on a die roll and present it to the user.  I looked at the roll templates and Powercards and neither allowed for this.  So I went the api approach.  Here's the basic structure: Step 1: On the character sheet itself I altered the buttons to make an API call: <button name="roll_meleehit" type="roll" value="!edy {{--title:@{meleeweaponname}|--subTitle:'sub'|--characterName:@{character_name}|--action:attack|--weaponType:@{meleeweapontype}|--weaponCat:@{meleeweaponcat}|--class:Melee|--character:@{character_name}||[[@{WeaponSkill}+(?{Aim | Half aim (+10),+10 | No aim (+0),+0 | Full aim (+20),+20} + ?{Attack Type | All out (+30),+30| Charge (+20),+20 |Standard (+10),+10 | Swift Attack (+0),+0 | Lighting (-10),-10} + ?{Modifier|0})]] }}"> <span data-i18n="hit-u">Hit</span> </button> Step2: I created a script to handle the api call on("chat:message", function(msg) {     if (msg.type !== "api") return;     if(msg.content.indexOf("!edy") !== -1) { Step 3: Within my script I get all my passed in arguments and do the needed calculations.  I actually decided to just do the 1d100 roll in the script  var roll = randomInteger(100); //between [1,100] Step 4: Once the calculations are done I create some html and display it in the chat console. sendChat("", '/desc ' + cardHtml); That's basically it.  I'm new to all this so maybe there is a better way but this was what I was able to figure out.  Having the backend api script is really key as I'm now able to display any information I want.  The hardest part was really just figuring out the syntax to make all the calls hook up. I hope this helps someone.