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

Hot to get detailed rolls

Hello, sorry if this is the wrong place. I am trying to modify the call of chtulhu 7ed available here <a href="https://github.com/Roll20/roll20-character-sheets/tree/master/Call_of_Cthulhu_7th_Ed" rel="nofollow">https://github.com/Roll20/roll20-character-sheets/tree/master/Call_of_Cthulhu_7th_Ed</a> to add some custom rules. Right now i am looking at roll templates, the sheet have by default: What i would like to do is to have the detail of the damage, what we see in the mouseover : (4+7)+2+0 and not the result 13, or even better to have the detail and the result, like (4+7)+2+0 = 13. i dont think the last solution is possible, but since the mouseover have the detail, i believe it should be possible to have this detail instead of the result. I tried playing with the bracket [[]] in the roll template and in the weapon damage, but i am only able to have the roll as string : 2d8+2+0 but not the detailed version of the roll itself. Any idea what i am missing and if what i want to do is doable? Thanks.
1625801334

Edited 1625801372
David
Sheet Author
Take a look at this&nbsp; <a href="https://app.roll20.net/forum/post/8716289/processing-dollars-0-dot-dot-dot-is-it-possible/?pageforid=8716289" rel="nofollow">https://app.roll20.net/forum/post/8716289/processing-dollars-0-dot-dot-dot-is-it-possible/?pageforid=8716289</a> and this&nbsp;<a href="https://wiki.roll20.net/Reusing_Rolls" rel="nofollow">https://wiki.roll20.net/Reusing_Rolls</a>
Thanks David, indeed interesting link! first try is not good, it seems that what i have in $[[X]] is the computed value too, for example: $[[0]] contains 40, $[[4]] contains 7
1625879037
GiGs
Pro
Sheet Author
API Scripter
You'll need to post the full text of the macro you are using, and also what is supposed to appear in the Deg. box.
1625879091
Oosh
Sheet Author
API Scripter
You'll need to dig deeper into it. The $[[0]] indexing covers the entire chat command (so everything in that template), roughly in order of left to right, working from inner brackets to outer brackets. With deeply nested rolls, this order becomes pretty unreliable, with the parser skipping ahead to inner rolls further in the template before returning to finish off outer brackets. To see what all the rolls are, just add 0.$[[0]] 1.$[[1]] 2.$[[2]] ...... 20.$[[20]] a bunch of references to the template somewhere so you can see what order they end up in. If the number of [[ rolls ]] contained in the template isn't 100% reliable, you're still going to run into issues since there's no way to dynamically figure out the correct index. For example, if there was a 4th [[ Stat ]] in the top row, it's going to ruin your hard-coded indexing if it's based on 3.
@Oosh,what do you mean just add 0? Any index after $[[4]] is "INVALID INLINE ROLL!" so in the last picture i posted, as you say 0 contains 40, 1 contains 8,... , 4 contains 7. code from: <a href="https://github.com/Roll20/roll20-character-sheets/blob/master/Call_of_Cthulhu_7th_Ed/coc_7th_ed.html#L3865" rel="nofollow">https://github.com/Roll20/roll20-character-sheets/blob/master/Call_of_Cthulhu_7th_Ed/coc_7th_ed.html#L3865</a> &lt; button class =' new-roll ' type =' roll ' value =' &amp;{template:coc-attack-1} {{name=@{weapon1_inv_name}}} {{success=[[@{weapon1_inv_skill}]]}} {{hard=[[floor(@{weapon1_inv_skill}/2)]]}} {{extreme=[[floor(@{weapon1_inv_skill}/5)]]}} {{malf=@{weapon1_inv_malf}}} {{roll1=[[1d100]]}} {{damage=[[@{weapon1_inv_damage}@{weapon1_inv_db}]]}} ' name =' roll_weapon1_inv_attack ' /&gt; with @{weapon1_inv_damage} and @{weapon1_inv_db} coming from text box containing string rolls (2d8+2 for example). so yeah i will have an index issue at some point. The roll20 tooltip have the right info without index issues, but it does nt come from the template
1625892023

Edited 1625892141
Oosh
Sheet Author
API Scripter
Ah, I see. Sorry, I misunderstood. You can only call the results of each [[ roll ]] inside its own square brackets. So you need to wrap each part you want to be able to call back to in its own [[ ]] brackets: {{damage=[[ [[ @{weapon1_inv_damage} ]] + [[ @{weapon1_inv_db} ]] ]] }} In this case if there's no other rolls in the line you'd have $[[0]] inv_damage, $[[1]] inv_db, and $[[2]] total. ( Parentheses ) don't count as individual roll expressions, and cannot be called with an index. If those @{attribute} calls, like @{weapon1_inv_damage}, also contain multiple parameters which you'd like to call individually, you'll also need to edit those and wrap each one in [[ brackets ]].
Ho ! i see now ! Thanks @Oosh ! I now understand the indexing and the nested brackets. If those @{attribute} calls, like @{weapon1_inv_damage}, also contain multiple parameters which you'd like to call individually, you'll also need to edit those and wrap each one in [[ brackets ]]. That's my case, but I see why now, is there any easy way to do that? Trough a worker? To complete my answer: @{weapon1_inv_damage} must be a roll string, for example ' 2d8+2' @{weapon1_inv_db} can be a int
1625895617

Edited 1625895634
I did more testing, i confirm what you saying if i replace in the text box: 2d8+2 give me the details if i enter [[2D8]]+[[2]] instead. in fact i should be doing&nbsp; [[D8]] + [[D8]]+[[2]] if i want the breakdown the 2d8. Now i cannot really ask my players to add the bracket. Is there a programmatic way to parse my&nbsp; 2d8+2? I imagine a workaround would be to have a dropdown with damage values and hard code the values of each item. That would fix the dynamic index issue coming right after :D
1625901592
Oosh
Sheet Author
API Scripter
Hrmmm.... it depends on exactly what kind of output you'd like. If you're happy with just the roll expression itself being printed out, you should be able to get that effect by removing the roll brackets entirely, before adding them back to turn it into an actual roll: {{damage=Rolling "@{weapon1_inv_damage} @{weapon1_inv_db}" = [[ @{weapon1_inv_damage}@{weapon1_inv_db} ]] }} This should work provided none of the @{weapon1_inv_damage} references have any [[ sub-rolls ]] in them, though it's going to directly print out the "2d8" rather than roll them. If you did want full control over every part of the roll, you could write a sheetworker to listen for changes/additions to the section, and run a replacer function on it. Here's an example (it's not at all robust, it doesn't even handle * or / signs.... just a quick example!) let &nbsp; example1 &nbsp;=&nbsp; `4&nbsp;+&nbsp;3d8&nbsp;+&nbsp;2` ; let &nbsp; example2 &nbsp;=&nbsp; `1d4&nbsp;+&nbsp;5&nbsp;+&nbsp;@{weapon1_damage_bonus}` ; const &nbsp; rollWrapper &nbsp;=&nbsp;( rollExpression )&nbsp; =&gt; &nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp; return &nbsp; rollExpression &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;. replace ( / ( \d + )([ dD ] \d + ) / g ,&nbsp;( match ,&nbsp; part1 ,&nbsp; part2 )&nbsp; =&gt; &nbsp;{&nbsp; //&nbsp;expand&nbsp;XdY&nbsp;rolls&nbsp;&amp;&nbsp;wrap&nbsp;separately &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let &nbsp; output &nbsp;=&nbsp;[]; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for &nbsp;( let &nbsp; i = 0 ;&nbsp; i &lt; part1 ;&nbsp; i ++)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; output . push ( `[[ ${ part2 } ]]` ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return &nbsp; output . join ( '&nbsp;+&nbsp;' ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;. replace ( / ( ^| [ +- \s ])( \d + )([ +- \s ] |$ ) / g ,&nbsp; `&nbsp;[[$2]]&nbsp;` )&nbsp; //&nbsp;wrap&nbsp;lone&nbsp;integers&nbsp;so&nbsp;they&nbsp;can&nbsp;be&nbsp;called &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;. replace ( / ( @{ [^ } ] *? } ) / g ,&nbsp; `&nbsp;[[$1]]&nbsp;` );&nbsp;&nbsp;&nbsp; //&nbsp;wrap&nbsp;@{attribute}&nbsp;references } //&nbsp;Expected&nbsp;Output: //&nbsp;rollWrapper(example1)&nbsp;==&gt;&nbsp;[[4]]&nbsp;+&nbsp;[[d8]]&nbsp;+&nbsp;[[d8]]&nbsp;+&nbsp;[[d8]]&nbsp;+&nbsp;[[2]] //&nbsp;rollWrapper(example2)&nbsp;==&gt;&nbsp;[[d4]]&nbsp;+&nbsp;[[5]]&nbsp;+&nbsp;&nbsp;[[@{weapon1_damage_bonus}]]&nbsp; It's a bit of work making sure your replacer won't choke on anything players might type in to the character sheet, though. The above is super rough and could easily be tripped up. The first option is much easier :)
The output i would like to have is the same as the default one when we do a /roll: So the detail of each roll and the total. We are playing call of cthulhu, there is not that much dices involved in damages. I think i will go with the first workaround: having a dropdown for the dices and hardcode values, something like: &lt; select name ="attr_weapon1_inv_damage" &gt; &lt;option value="[[d3]]"&gt;1d3&lt;/option&gt; &lt;option value="[[d4]]"&gt;1d4&lt;/option&gt; &lt;option value="[[d6]]"&gt;1d6&lt;/option&gt; &lt;option value="[[d8]]"&gt;1d8&lt;/option&gt; &lt;option value="[[d10]]"&gt;1d10&lt;/option&gt; &lt;option value="[[d12]]"&gt;1d12&lt;/option&gt; &lt;option value="[[d20]]"&gt;1d20&lt;/option&gt; &lt;option value="[[d3]]+[[d3]]"&gt;2d3&lt;/option&gt; &lt;option value="[[d4]]+[[d4]]"&gt;2d4&lt;/option&gt; &lt;option value="[[d6]]+[[d6]]"&gt;2d6&lt;/option&gt; &lt;option value="[[d8]]+[[d8]]"&gt;2d8&lt;/option&gt; &lt;option value="[[d10]]+[[d10]]"&gt;2d10&lt;/option&gt; &lt;option value="[[d12]]+[[d12]]"&gt;2d12&lt;/option&gt; &lt;option value="[[d20]]+[[d20]]"&gt;2d20&lt;/option&gt; &lt;option value="[[d3]]+[[d3]]+[[d3]]"&gt;3d3&lt;/option&gt; &lt;option value="[[d4]]+[[d4]]+[[d4]]"&gt;3d4&lt;/option&gt; &lt;option value="[[d6]]+[[d6]]+[[d6]]"&gt;3d6&lt;/option&gt; &lt;option value="[[d8]]+[[d8]]+[[d8]]"&gt;3d8&lt;/option&gt; &lt;option value="[[d10]]+[[d10]]+[[d10]]"&gt;3d10&lt;/option&gt; &lt;option value="[[d12]]+[[d12]]+[[d12]]"&gt;3d12&lt;/option&gt; &lt;option value="[[d20]]+[[d20]]+[[d20]]"&gt;3d20&lt;/option&gt; &lt;/select&gt; and same for weapon bonus If a value is missing it will be easy to add one or players can type the roll themselves. As you said @Oosh, writing a rollwrapper can be troublesome. Thanks again for your help, its greatly appreciated.
Update after testing the workaround if anyone is interested: not working to the fact that there is still a potential index issue. It is not possible to know if we have 1 or 3 [[X]] as dropdown values.
1626143517
GiGs
Pro
Sheet Author
API Scripter
Yes, you cant use the Reusing Rolls technique unless the number of inline rolls is consistent and never changes, because of the index issue.
1626262474
Oosh
Sheet Author
API Scripter
Ok, so with the update that just came through with the startRoll() and finishRoll() functions, you can now do what you were trying to do :) Of course, if you've found another solution it's probably not worth reworking it, but happy to help with the function if you'd like.
Thanks @GiGs and Oosh, for those interested startRoll() is explained here . For now i will see with my players if they are ok with the roll description ("2d8+2") and the result. It's a bit better than what we had. If they bug me too much ill give a try for the worker ;)