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

[custom roll parsing] changing what the hover shows

1637047995

Edited 1637054361
Matthew C
Pro
Sheet Author
Hey all, first of all I am quite new to the custom roll parsing, but the character sheet I am working on has quite unique rolls and without this that involves around 1000 lines of roll greater than this but less than this roll and greater than this roll but the same as this roll yadda yadda yadda and using the roll parsing I can cut down on that by a crap ton, but I was curious if it is possible to change what it shows: an example on('clicked:passive', (info) => {         startRoll("&{template:passiveDefence} {{type=?{Type|Defence,[[1]]|Resistance,[[2]]}}} {{mitigation=@{mitigation}}}                 {{roll2=}} {{roll=[[1d10]]}} {{whelming=[[1d10]]}} {{bonus=(?{Bonus Modifier|0})}} {{target=[[?{Target's Modifier|0}]]}}                 {{targetDouble=[[?{Target's Modifier|0}*2]]}} {{targetHalf=[[?{Target's Modifier|0}/2]]}} {{defence=@{defence}}}                 {{overwhelming=[[10+1d10+(?{Bonus Modifier|0})]]}}  {{underwhelming=[[1-1d10+(?{Bonus Modifier|0})]]}}                 {{resistanceRoll=[[1d10+(?{Bonus Modifier|0})+@{resistance}-(?{Target's Modifier|0})}}                   {{resistanceOverwhelming=[[10+1d10+(?{Bonus Modifier|0})+@{resistance}-(?{Target's Modifier|0})]]}}                   {{resistanceUnderwhelming=[[1-1d10+(?{Bonus Modifier|0})+@{resistance}-(?{Target's Modifier|0})]]}}", (results) => {             const roll = results.results.roll.result;             const overwhelming = results.results.roll.result + results.results.whelming.result;             const underwhelming = results.results.roll.result - results.results.whelming.result;             console.log(results.results.roll);             const computed = roll === 10 ? overwhelming : roll === 1 ? underwhelming : roll;             finishRoll(                 results.rollId,                 {                     roll: computed                 }             );         });     }); To make it quick, basically a "crit" or "fumble" rolls a second 1d10 and either adds or subtracts it to the base roll. The good part is that the value I send back is correctly either normal, higher or lower based on the roll, however when you hover over the roll it simply says "Rolling 1d10 = (16)" which everyone should be able to tell means that this was a 1d10 + 1d10 but is it possible to show that? Or in the case of the negative that it shows 1d10 - 1d10? Or better yet show something like "Rolling 1d10 (10) + 1d10 (6) = 16? I do not mind showing or hiding the rolls depending on what is needed if someone has any idea whatsover that would work for this To give an idea, the current method I was using before this was litterally roll 3 times, one was 1d10, one was 10+1d10 and the other was 1-1d10 and based on whether the first roll was a fumble, crit or normal it would choose which to show Basically right now we can edit the "results.results.<roll>.result", but what I want to do is edit "results.results.<roll>.expression"
1637104646

Edited 1637105138
Oosh
Sheet Author
API Scripter
According to the CRP brief from Roll20, a computed roll will always show the original formula on hover. You can certainly try some novel approaches and see if you can convince it otherwise - it may be possible somehow. The other approach would be to build your own tooltip. Here's a (totally untested) suggestion: - Apply some CSS to the .inlinerollresult {pointer-events: none} to disable the quantum tip. Obviously use some parent class to narrow your selector so you don't disable all result tooltips, just the computed ones. - Give the roll result container a couple of children <div class="my-tooltip-hover>, <div class="my-tooltip-content"> - Give the 'hover' trigger the following CSS: {position: absolute, top: 0%, left: 0%, width: 100%, height: 100%, z-index: +1} - Give the 'content' the following CSS: {position:absolute, display: none} - The roll result container (parent of the other two) may need {position: relative} set so the absolute positioning anchors to it, not an ancestor further up That should give you a 'hover' <div> which overlays the roll result, and a hidden 'content' <div>. You then need your hover event listener on the hover div, and a bunch of CSS to make your content div look like a tooltip and not get in the way of the mask when it's displayed. I won't go into that since Google should have you covered if you don't already know how to do it. All that's left is to set up your roll template with a {{tooltip::computed}} property that gets inserted as the meat of the 'content' <div>, so you can do your roll parsing, then throw the tooltip info in there as a computed string. The tooltip itself (being a computed .inlinerollresult) is likely going to need some further CSS work to get it looking how you want it. Alternatively, you could try outputting the tooltip content as a second chat item with startRoll() so you don't need to compute the content. This will require some more intense CSS-fu to get looking like it was part of the previous template. To provide an alternative to the "alternatively", someone else may have a much simpler suggestion :)
1637127928
Matthew C
Pro
Sheet Author
Hey, thanks a bunch for all the tips, I will have to try them out. I will check in the other forum to see if someone suggested allowing us to change more than just the result so I can +1 it, otherwise I might pop in the suggestion myself, since if we can see it and modify part of it, we should be able to modify all of it, roll20 just didn't give us the needed tools to do so
1637132716
Matthew C
Pro
Sheet Author
As an update of what I am going to attempt when I have the time, but maybe someone can already tell me whether or not it would be smart. The main issue I have is with my system you roll a 1d10 and if you roll a 1 or a 10 you roll a second time subtracting the second roll or adding the second roll respectively (So kinda like exploding and reverse exploding) So what I was thinking, is making a button that makes a roll to simply check for critical failure and critical success and would then return the roll value and based on the roll value 1,10, rest would call a second roll which is actually printed to the chat Do you guys think this could/would work
1637133301
.Hell
Sheet Author
The Witcher TRPG sheet does the exact same thing. It ignores the tooltip issue but shows the other information. Maybe you can steal something from there :)
1637133556
Matthew C
Pro
Sheet Author
.Hell said: The Witcher TRPG sheet does the exact same thing. It ignores the tooltip issue but shows the other information. Maybe you can steal something from there :) Sweet, thanks I will have to look at that sheet, always nice to have examples of what you are looking for in a working sheet
1637165544
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I've got a sheet releasing next week that does some stuff like this with exploding. It winds up sending multiple chat messages and formats the rolltemplates so that the continuations look like it's all one roll. The section above the red line is the first roll. The bottom section is a completely separate roll that was dispatched by the script in response to the max roll on the d8. Because an 8 was rolled on a d8, it explodes into a d10. Then the actual total used for the roll is the two highest dice values.
1637213565
Matthew C
Pro
Sheet Author
Thanks, using 2 rolls isn't a bad idea either, will have to keep that in mind