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

Resend inlineroll

1635707357

Edited 1635707467
Eric
Sheet Author
Hi ... I'm trying to capture the inline rolls in an API script, examine the roll results (to count successes and failures), and then to send a second message to a roll template that will show the original inline roll (yellow highlighted with hover popup) as well as my counts for successes and failures. I can examine the roll results and do the successes/failures counting. My issue is how do I send the inlineroll via sendChat to a roll template so that it shows yellow with the hover ability? The inline roll I want is the first one (position zero) ... msg.inlinerolls[0] For example ... using a roll button in the char sheet, the button value would be something like ... value='&{template:swingresults} {{the_roll=[[?{Dice|2}d20sacs<@{Melee_Focus}cf20<@{Melee_TN}]]}}' So in the API script something like this to send to the swingcounts template (note I just hardcoded the successes/failures counts for brevity)... sendChat("  ","&{template:swingcounts} {{successes=3}} {{failures=1}} {{the_roll="+msg.inlinerolls[0]}} I don't want to reroll a new roll, I want to return their original roll to the template for display. The above sendChat, only shows  [object Object]    on the template output in chat, which makes sense since. So is there a way to send the "the_roll" back to the second template swingcounts to be shown as a inline roll?
1635714357

Edited 1635714474
The Aaron
Roll20 Production Team
API Scripter
Tim's libInline will let you do that. It's in the 1-click. 
1635720798
Eric
Sheet Author
Oh that's perfect!  Thanks for pointing that out.   Cheers!
1635738570
Eric
Sheet Author
As a follow up on my topic ... I've implemented the libInline library and it does indeed help with sending the roll tip from the API script back to a char sheet roll template. Now as I progress through my development, it appears that the rollGreater() and rollLess() template helper functions do not recognize the rolls when sent from the API to the template. In my template I have several "check" variables to conditionally display values, such as ... {{#rollGreater() encumbered 0}} <p>You are encumbered!</p> {{/rollGreater() encumbered 0}} As part of the roll button VALUE in the character sheet, it sends like this, which works fine when sent from the char sheet button. ... {{encumbered=[[@{checkbox-encumbered}]]}} ... In the API sendChat, I have this in the string ... {{encumbered="+msg.inlinerolls[expertise_chk_index]+"}} I also tried adding the inline roll identifier [[ ]]  however that causes a runtime error in the roll20 parser ... {{encumbered=[["+msg.inlinerolls[expertise_chk_index]+"]]}} I also tried sending using the various function results in the libInline library, however none seemed to trigger the template rollGreater() check. What do I need to send in the sendChat for the template helper functions to work? Cheers and thanks for comments.
1635775684
The Aaron
Roll20 Production Team
API Scripter
The libInline library can only create the format of the rolls to give you the hover text and highlighting.  To get the Roll Template to display correctly, you'll have to send rolls for those places where it's doing a comparison.  You could recreate the rolls for the test if you know they will be static results: ... {{encumbered=[[@{ some-char-name |checkbox-encumbered}]]}} ... Or create surrogate rolls that have a similar value: ... {{encumbered=[[ 60d1 ]]}} ... It's hard to say precisely, but I hope that helps. 
1635814366
Eric
Sheet Author
Damn ... yes I should have thought of that already myself.  Yes, they are static at the point the API gets them; they are just 1 or 0 flag values. I can send those as rolls. Thanks again.