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

Roll result structure

1479992718
Laurent
Pro
Sheet Author
API Scripter
Is there a place where I could find the full specification for roll results structures (as contained in the inlineroll property of chat messages)? In the API wiki, there seem to be two examples only, and that is not enough for my needs...
1480001095

Edited 1480001363
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I don't think there is anything in the wiki. The best way I've found (other than pestering Aaron ;) ) is to log a message that has the things I'm interested in in it. Here's the log of a decently comprehensive chat message; it certainly doesn't have everything possible in it, but should give you some ideas. {"content":" {{name=Test Roll}} {{Normal Roll=$[[0]]}} {{Custom Crit=$[[1]]}} {{Success/Failure=$[[2]]}} {{Multiple rolls = $[[4]]}}","inlinerolls":[{"expression":"1d20","results":{"resultType":"sum","rolls":[{"dice":1,"results":[{"v":6}],"sides":20,"type":"R"}],"total":6,"type":"V"},"rollid":"-KXLul9KKSoOj9L0rOwq","signature":"34e5a6347924f66459719ba3d063aaa93ed7607f9d5f7b8903277a7e42093c6cab7166ec15ff40a43dd227bdb63822eb767ea2df1b37fbacea3af9f796de3b36"},{"expression":"1d20cs>18","results":{"resultType":"sum","rolls":[{"dice":1,"mods":{"customCrit":[{"comp":">=","point":18}]},"results":[{"v":1}],"sides":20,"type":"R"}],"total":1,"type":"V"},"rollid":"-KXLul9LziGsp_iGtqr8","signature":"b0dcd6f751950e6d57612f2384e0356172ceb42d2d13e703b244eb1aeb523c3c1d1149e824433073a819f146db62ed5311ee83b26b6a734892d3731a0230bad8"},{"expression":"1d20>10","results":{"resultType":"success","rolls":[{"dice":1,"mods":{"success":{"comp":">=","point":10}},"results":[{"v":13}],"sides":20,"type":"R"}],"total":1,"type":"V"},"rollid":"-KXLul9LziGsp_iGtqr9","signature":"00b0e42cdcb28a0f8b7b712631b088799a7ff1b91c2b788d4f627807993d503030bf9b56c91cfc0f13f147aab39a48df9ecb54eb5077b560d4040dfbdd2783b9"},{"expression":"2d4+5","results":{"resultType":"sum","rolls":[{"dice":2,"results":[{"v":1},{"v":4}],"sides":4,"type":"R"},{"expr":"+5","type":"M"}],"total":10,"type":"V"},"rollid":"-KXLul9NKK98JtuY3C7X","signature":"5727eeeedbfd3aff93c4ca4a502c3e334266dbe21d730350c2df9709a58efc001b2d2ffce507ec924d7a4d982cef81d9879dfa5904447ce0b85dc3e53b9ba231"},{"expression":"1d20 + 1d8 +10","results":{"resultType":"sum","rolls":[{"dice":1,"results":[{"v":15}],"sides":20,"type":"R"},{"expr":"+","type":"M"},{"dice":1,"results":[{"v":7}],"sides":8,"type":"R"},{"expr":"+10","type":"M"}],"total":32,"type":"V"},"rollid":"-KXLum7BsJB9aC3Dp8Is","signature":"22bfe787312c900f13d093277c4ca92c607d85a9215373c720bef9be1aa810e4887f672c44d4c0fa8d76c3c1c32edf0788f83447bb81fe52037bb8246ef47016"}],"playerid":"-KGjaNNHFr84Ghmzccnh","rolltemplate":"default","type":"general","who":"Scott C. (GM)"} The Chat message for comparison was: &{template:default} {{name=Test Roll}} {{Normal Roll=[[1d20]]}} {{Custom Crit=[[1d20cs>18]]}} {{Success/Failure=[[1d20>10]]}} {{Multiple rolls = [[1d20 + 1d8 +[[2d4+5]]]]}} What are you looking for exactly? There may be something out there to give some more specific examples of how to parse down to what you want. Scott
1480006203
Jakob
Sheet Author
API Scripter
It's a bit mysterious. I can tell you what I learnt by picking out the stuff I needed for a script recently. An inlinerolls object has top level expression, rollid, signature, and results properties (maybe more that I forgot?) - all the interesting stuff is in the results. Results has a nested structure; every roll has a type property, and some types have a rolls property that contains other sub-rolls of that expression. The types I've found (in pretty much the way Scott has suggested), along with some information, are these (notably omitted are nested inline rolls). V  It seems this is always the type of the top-level roll (i.e. of msg.inlinerolls[i].results). It has a rolls property, which is an array containg all the sub-rolls, as well as a total property equal to the total result. It also has a resultType property, which seems to have a value of either sum or success, although there may be more I have missed. R This a single dice roll (2d6 would be a single roll in this context). It comes with a sides property, possibly a mods property if you have given it modifiers (such as a custom critical range or things such as drop lowest or count successes), and a results property, whose value is an array of objects. Each of these objects has a 'v' property (result of the roll), and can also have a 'd' property if a die is dropped from the result. G  This is a grouped roll (i.e. what you get from curly braces), and basically a combination of V and R . They can have the mods or success properties (as in R ), as well as a resultType property (as in V ). It has a results property (as in R ), and a rolls property; the rolls property is an array, each member of which is itself an array which contains subrolls for each part of the grouped expression - i.e. {1d8+1d6,1d6} would lead to a rolls property like this: [         [         {           "dice": 1,           "results": [           {             "v": 3           }],           "sides": 6,           "type": "R"         },         {           "expr": "+",           "type": "M"         },         {           "dice": 1,           "results": [           {             "v": 4           }],           "sides": 8,           "type": "R"         }],         [         {           "dice": 1,           "results": [           {             "v": 6           }],           "sides": 6,           "type": "R"         } ] ] M  These are mathematical expressions with no dice rolls involved. They seem to only ever have an expr property containing just what you would expect (e.g. '+2'). L These are roll tags. They have a text property containing the tag text (without braces).
1480078723
Laurent
Pro
Sheet Author
API Scripter
Thanks Jakob and Scott, that helps already. I'm trying to do some custom display of the rolls. Do you know if the structure stores whether the result is a critical success, or if we must compute it using the mods property?
1480083425
Jakob
Sheet Author
API Scripter
Laurent M. said: Thanks Jakob and Scott, that helps already. I'm trying to do some custom display of the rolls. Do you know if the structure stores whether the result is a critical success, or if we must compute it using the mods property? You need to compute it yourself.
1480084124

Edited 1480090251
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yep, take a look at my customized roll listener for some parsing examples (I'm sure these could be done better than I have). <a href="https://app.roll20.net/forum/post/4259054/script-customizable-roll-listener/?pageforid=4259054#post-4259054" rel="nofollow">https://app.roll20.net/forum/post/4259054/script-customizable-roll-listener/?pageforid=4259054#post-4259054</a>
1480088276
Laurent
Pro
Sheet Author
API Scripter
Thank you Scott, I can refer to your code to understand the structure now. E.g. I found there that the customCrit list is encoding the conjunction of the comparisons.
1480090240
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
glad to be of help. Just remember you need to handle custom crit/fumble and handle when there is not a custom crit/fumble (e.g. just a 1d20 instead of 1d20cs&gt;18).