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

Is it possible to customize the inline roll display ?

Hello, I have done some scripts to manage spell, buff, attack and I'm creating a new on in order to enhance the display of the older one. In this script I am using some html code to make the chat prettier and I'm stuck with the inlineroll which don't take the format of the surrounding tag. For example  <span style='background:#000000;color:#ffffff; float:right;margin-top:0px;padding:0px; font-family:" + CARD_FONT_NOTE + ";font-size:" + CARD_FONT_NOTE_SIZE + ";'>Concentration [[1d20]]</span> With this code the label Concentration is correctly display (white on black is just for test :p) but the inline roll keep it's yellow background color and the font is ignored. Is there a a simple way to change it ? I'm using Diana d&d 3.5 sheet if it's any utility
1650119273
GiGs
Pro
Sheet Author
API Scripter
The styling code there only affects the character sheet. If you want to change how things look in chat, you need to edit the rolltemplate part of the sheet's code.
1650122984
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
GiGs said: The styling code there only affects the character sheet. If you want to change how things look in chat, you need to edit the rolltemplate part of the sheet's code. This is for the chat output from an API script, not a char sheet. Unfortunately, API scripts don't have any way to customize how an online roll looks that I'm aware of.
1650123428
GiGs
Pro
Sheet Author
API Scripter
Scott C. said: This is for the chat output from an API script, not a char sheet. Hehe, I didn't realise that. I should have looked at which forum we are in.
1650132445
vÍnce
Pro
Sheet Author
One option might be to use a Stylus css override to make it look however you want after it's posted.  Of course this only changes your view of the result.(unless the rest of your group installs the same override).
1650149215

Edited 1650149671
Oosh
Sheet Author
API Scripter
You can reconstruct the roll yourself, other wise as others have said, no. You'll lose the quantum roll icon, and the tooltip will have an 'API generated' tag, but otherwise you can put any valid inline styles you like in there. Tim & Aarons libInline can do all the heavy lifting for you if you don't want to learn how the roll object is constructed. It can return the roll total and the tooltip string which you can then throw in whatever element you want. You might need to run a quick string replace on the return from libInline if you do use it, though.
Hi, thanks for your your reply. It's in api script for chat outpout, I should have precise it.  Oosh I will look into the libInline after my holidays :)
1650237694

Edited 1650237853
Oosh
Sheet Author
API Scripter
No worries, here's a minimal working example to check out when you get back to it (I hope this isn't the color scheme you go with....): on ( 'ready' , () => {   on ( 'chat:message' , msg => {     if ( msg . inlinerolls ) {       const roll = libInline . getRollData ( msg )[ 0 ]. getRollTip ();       sendChat ( '' , `libInline: ${ roll } ` );       const roll2 = roll . replace ( / ( style=" [^ " ] + ) "/ , '$1 background-color:blue; color:white; border: 2px solid cyan;"' );       sendChat ( '' , `libInline modified: ${ roll2 } ` );     }   }); }); edit - you probably don't want to inline the border color like I've done, as you'll lose crit color borders.
I tried to call libInline but it always return undefined or empty result. Its seems inlinerolls are roll20 object, I tought it was a string between double brackets :/ I don't want to catch existing roll in the chat but display a new one, is it possible to create it from a string like [[[[{floor((10+2)/3),4}kl1]]d10]] ?
1650723582
timmaugh
Pro
API Scripter
Hey, David... care to share how you were trying to use libInline? If there truly is a problem I should fix it. My guess, though, is that maybe you didn't know what to expect when you employed the library. Yes, the inlineroll object is an object, but it's a simple javascript object... nothing different about how you would access it (no get/set, for instance). What the libInline library does is build handles for the important parts of the roll so you don't have to parse it all the time. Here's Oosh's example where he uses the getRollData() function of the libInline library. libInline.getRollData(msg)[0] This is one formation of what the function will accept. The different formations are all detailed more thoroughly in the libInline thread , but basically, the getRollData() function can take an inline roll as a parameter: libInline.getRollData(msg.inlinerolls[0]) ...or an array of such rolls: let myRollArray = [msg.inlinerolls[0], msg.inlinerolls[2], ...msg.inlinerolls.slice(5)]; libInline.getRollData(myRollArray) ...in fact, since the inlinerolls property of the message object is an array of rolls, you can just pass it, to process all of the rolls: libInline.getRollData(msg.inlinerolls) ...or, the last formation of the function is that it can accept an object with an inlinerolls property, like the original message object. This is what Oosh did, above... just passing the msg object and getting the roll data back. So now you've sent your data in, what do you get back? You get back an array of objects with handles that let you manipulate the data. You don't get back just the rolltip. You get that back as one of the accessible properties of the roll. In Oosh's example, he feeds the msg object to the function, which returns an array of parsed roll objects. libInline.getRollData(msg) He then asks for the first roll from that list: libInline.getRollData(msg) [0] He still hasn't assigned it to his variable, though. (Although he could.) Instead, he next asks to get the roll tip from this object, using one of the functions attached to the parsed roll object: libInline.getRollData(msg)[0]. getRollTip() NOW he has the roll tip as a string, which he can send to the chat (or manipulate, etc.) To Your Need You might have a more hands-on need of the library, if you want to take the rolls and reprocess them. For that, you might want to use the getDice() function. You can use it directly from the library by supplying a roll from the message object and a type, or you can use it as a function attached to the particular roll object you're working with. Here is an example using the first method: let dicearray = libInline.getDice(msg.inlinerolls[0],'included'); That gets the included dice (ie, those not dropped). With that array, you can build your own roll tip. Here is a version using the roll object as returned from the getRollData() function: let myRoll = libInline.getRollData(msg.inlinerolls[0]); let dicearray = myRoll.getDice('included'); So you can build your parsed rolls array using the getRollData() function, and then mapping a new roll tip to it, which you would build: let parsedRolls = libInline.getRollData(msg).map(r => {     r.customRollTip = r.getDice('included').map(d => {       // ...code to process each die in the array, turning it into HTML code...       return d;     }).join();     return r;   }); That would give you an array of parsed rolls with not only the libInline handles, but also your customRollTip property that you could access as necessary. Note that I used the getDice() function, above. Since each of the parsed rolls returned from the getRollData has a getRollTip() function attached to it, too, you could start with the roll-tip that libInline builds, and then perform certain replacement operations on it, if that might be quicker.
1650723776
timmaugh
Pro
API Scripter
Also, note, that what you're describing "a string between double brackets" is what is called the roll expression, if you're looking at an inline roll object. If that is all you want -- for instance, you want to build your own roll parser -- you can look at the expression property. msg.inlinerolls.forEach(r => log(r.expression));
Thanks Timmaugh for your reply. To be clear I have no doubt the library work as intentend, it's just I'm not sure I can use it for my situation. According to the example kindly provided by Oosh an you it catch the inlineroll in the chat and provide several methods to manipulate it in order to modify it especially the appearance. Maybe I'm too narrow minded but I don't see how I can use it without the first inlineroll coming from the chat. I haven't explain my context : my script actually generate a spell card parsing the spell's handout. The note came from a copy/paste of a d&d 3.5 french site and no problem anymore with it, the gm note containing a json structure to create summon's token of inflicted damage etc. It works well for quite a time and I'm refreshing the interface. So in my case the msg calling the api won't content any inlineroll. First I tried to call the  getRollData  with the expression string in parameter and that's why I said it return empty meaning I'm not using the library correctely (but since I'm not english native I may have not said it correclty). I have created a new script to log  libInline.getRollData(msg)[0] . Now I saw what it looks, I am trying to recreate this object but I am not confident with javascript. I have initiliazed an object looking like the one I log but seems I missed something since the librayry return undefined. on('ready', () => {   on('chat:message', msg => {       let test = {"expression":"1d6+4","parsed":"(2)+4","resultType":"sum","total":6,"value":6,"labels":[],"tableReturns":[],"display":"(<span class=\"basicdiceroll\">2</span>)+4","dice":[{"v":2,"type":"","display":"<span class=\"basicdiceroll\">2</span>"}]};       log(test);       roll = libInline.getRollData(test);       log(test);     if (msg.inlinerolls) {       /* working example       let roll = libInline.getRollData(msg)[0].getRollTip();       sendChat('', `libInline: ${roll}`);       const roll2 = roll.replace(/(style="[^"]+)"/, '$1 background-color:blue; color:white; border: 2px solid cyan;"');       sendChat('', `libInline modified: ${roll2}`);*/     }   }); });
1650813408

Edited 1650813432
timmaugh
Pro
API Scripter
Ah! So what you want to do is to build the *original* roll object. You're asking libInline to parse an object which already looks like what libInline will output. That won't work. It looks like you the component parts of the roll -- you have the equation/expression, and you can get or generate the numbers to fill in. In that case, you really have 2 options: You can build an original roll object, and then feed it to the libInline library to see what the rollTip comes back as... OR... You can just build the rollTip since you have the parts (really just a matter of displaying a formatted tip associated with hovering over the chat display). Even if you were going to do the second option, it might be easier to start by looking at a standard roll and examine the output libInline gives you... and once you're familiar with the rollTip format, shortcut the process and build the tip yourself. In any case, I just shared a debug script I use that can show you (in chat) the structure of both an original, Roll20-parsed inline roll object, as well as the returned, libInline-parsed roll object you get from the library. It's helpful to see the roll information no matter which direction you go, but *especially* if you go with the first option (where you're going to build a roll object to feed to libInline). * You can start there to really get a handle on the structure of an original roll. * - if you opt for the option where you build the roll yourself, there might be an easier path than building the roll, though. You can send a message with just the roll equation to Roll20, trap the return, and copy the inlineRoll object over to your message object. That will give you all the component parts... which you can use to either build your roll tip or shuttle out to libInline to have it process it for you. Post back if you what to go this direction but need help with making it work.