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

Capturing the roll from the Inline Roll

Hey guys. I am trying to capture the roll from an inline roll. value="&{template:statroll} {{result=[[(@{physstat} + ?{Modifier|0}) - 1d100]]}} I am able to display the result using the roll template but how do I display the roll? <rolltemplate> <table> <tr><td>Result: {{result}}</td></tr> <tr><td>Roll: {{roll}}</td></tr> </table> </rolltemplate> I can see the roll when I mouse over the number but I can't figure out how to capture the roll itself so I can display it in the chat. Can someone help :)
1518317438
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
This is how inline rolls work. It's not possible to show the roll separately.
1518319633
GiGs
Pro
Sheet Author
API Scripter
Since you're a Pro user there are ways to do this using an API script. If you are designing a character sheet for public use, that won't help, but if it's just for games where you're the GM, you can call the script with your character sheet.
Thank you both for the responses! At least I know now that the inline rolls can't show the rolls. How can I send chat strings out to the chat window from a worker script? I think I am going to have to rewrite all my inline rolls if I have to.
1518397001

Edited 1518397070
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Is the roll extremely necessary to display? or are you just wanting to display what modifiers went into the roll. If the latter, you can simply recreate that section of the roll in the contents of the sheet roll itself. Something like this: value="&{template:statroll} {{result=[[(@{physstat} + ?{Modifier|0}) - 1d100]]}} {{roll=@{physstat + ?{Modifier} - 1d100}}" This will of course not display what you rolled on that d100 separately from the rest of the roll, but would give the information about what else went into it. If you really do want to switch to /roll syntax rolls, it's certainly possible, although you will lose all roll template capability for that roll. Simply enter the macro code that you want sent to chat in the value of the sheet roll: value="/r (@{physstat} + ?{Modifier|0}) - 1d100 Hope that helps, Scott
1518400030
GiGs
Pro
Sheet Author
API Scripter
Aarani said: Thank you both for the responses! At least I know now that the inline rolls can't show the rolls. How can I send chat strings out to the chat window from a worker script? I think I am going to have to rewrite all my inline rolls if I have to. Here's a script I quickly edited from one I posted to a similar question: /* Call this as follows: !custom-roll-template [[1d100]] @{physstat} {?{Modifier|0} Be careful! it must begin with !custom-roll-template followed by a space, followed by an inline roll (in this case [[1d100]]) You can then have any number of modifiers, which must be simple numbers separated by spaces, or stat calls. For example: !custom-roll-template [[1d100]] 6 @{physstat} {?{Modifier|0} 17 23 -5 */ on('ready',function(){     'use strict';     on('chat:message',function(msg){         if('api' === msg.type && msg.content.match(/^!custom-roll-template/)  ){              let args = msg.content.split(/\s+/);                          if(msg.inlinerolls === undefined) { //msg.inlinerolls sendChat("Initiative","No Roll Detected"); return; }; let bonus = 0; for(var i = 2; i < args.length; i++) {                 bonus += parseInt(args[i])||0;             }             let roll = msg.inlinerolls[0].results.total;             let total = roll + bonus; //let outPut = '&{template:default} {{name=Custom Roll}} {{Result='+total+'}} {{Roll='+roll+'}}'; let outPut = '&{template:statroll}  {{result='+total+'}} {{roll='+roll+'}}';             sendChat(msg.who,outPut);         }     }); }); Post that in the API Scripts section of your campaign. Then in your character sheet, change this value="&{template:statroll} {{result=[[(@{physstat} + ?{Modifier|0}) - 1d100]]}} to this: value="!custom-roll-template [[1d100]] @{physstat} {?{Modifier|0}" So the button on your character sheet sends text to chat, which is intercepted by the script. The script than identifies the roll, and adds the bonuses to it to get a result. Then the sendchat line in the script sends text back to chat, and that is intercepted by your rolltemplate. It's pretty convoluted, but it works! Also, about your template, adding a second row might make it prettier. it'll make the numbers line up in the output, like this: <rolltemplate> <table> <tr><td>Result:</td><td>{{result}}</td></tr> <tr><td>Roll:</td><td>{{roll}}</td></tr> </table> </rolltemplate>