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

Passing Results of Dice Roll to API

What I am trying to do is pass an attribute and the results of a dice roll to the API script. This will allow a player to roll a 3D dice non-automatically (which my players love to do because it simulates throwing real dice on a table) and pass the resulting total to the API along with an attribute, then the API can use both numbers. Example chat command: !myscript @strMod /roll 1d20+5 Example script: on("chat:message", function(msg) { if(msg.type == "api" && msg.content.indexOf("!myscript") !== -1) { var slice = msg.content.split(" "); var strmod = parseInt(slice[1]); var rollresult = parseInt(slice[2]); The script is working fine but I do not know how to accomplish the chat command (to result in submitting "!myscript 4 19" or whatever, which works perfectly when i type it in manually) Thanks for any help received.
Cool stuff! Just FYI: Roll20 Wiki said: Dice Agency is on when the box labeled "Automatically Roll 3D Dice” in your games “My settings” tab in unchecked. With Dice Agency enabled, you will have complete control over how dice are rolled in game. You'll be given the ability to click-and-drag to indicate the direction and force with which the dice are thrown. Uncheck the Automatically Roll 3D Dice box to use the old "auto roll" method.
Yes I fully understand how that checkbox works. What I am trying to do is store the result of the roll and submit it to my API script seen above. I figured out the strMod portion by using this - !turningcheck @{CharachterName|AttributeName} What I need to do now is accomplish the same thing with a dice roll in the second slot. Something like this - !turningcheck @{CharachterName|AttributeName} @{/roll 1d20+5} Thanks for your help 
1452142801
Lithl
Pro
Sheet Author
API Scripter
You would not use the /roll command to send a roll as a parameter to an API command. You'll want an inline roll, like "!turningcheck @{Character Name|Attribute Name} [[1d20+5]]" Then, you'll have to inspect msg.inlinerolls to get the data on the roll.
1452143074
The Aaron
Pro
API Scripter
You might find this helper function useful:&nbsp;<a href="https://wiki.roll20.net/API:Cookbook#processInlinerolls" rel="nofollow">https://wiki.roll20.net/API:Cookbook#processInlinerolls</a>