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

Display Roll result

I have some inline roll objects I want to parse, and spit out to the chat. This is just a quick fix until the shadowrun 5e API dev comes along. I have never worked with the roll20 API or javascript before.  The line const roll = msg[0].inlinerolls[i] ? `[[${msg[0].inlinerolls[i].results}]]` :  `<a ${circles} href="!sr5 --rollInit --error">!</a>` I want to display the inner roll data in the same way a [[/r 1d6]] would be displayed. the die are *already* rolled, this is part of a callback function.  Does anyone know how I can do this? thanks! const displayInitiative = (msg,selected) => {     try {       let feedback = '';       log(msg[0].inlinerolls[0].results)       for (let i = 0; i<selected.length; i++) {         feedback += `<div style='display: inline-block; border: 1px solid ${third}; border-radius: 5px; padding: 2%; background-color: ${secondary}; margin-bottom: 3%; width: 95%;'>`         feedback += `<img src='${selected[i].src}' style='margin-right: 2%; width: 20%;'>`         feedback += `<label style='display: inline-block; font-weight: bold; font-size: 1.3em; color: ${third}; vertical-align: middle; width: 60%;'>${selected[i].name}</label>`         const roll = msg[0].inlinerolls[i] ? `[[${msg[0].inlinerolls[i].results}]]` :  `<a ${circles} href="!sr5 --rollInit --error">!</a>`         feedback += `<div style='color: ${accent}; width: 15%; display: inline-block;'>${roll}</div>`         feedback += `</div><br />`       }       sendChat(`${apiName} Roll Initiative`, `${header}</div>${feedback}</div>`);     } catch (error) {       errorMessage('displayInitiative', error)     }   },
1631760904
timmaugh
Forum Champion
API Scripter
Those inline rolls can be recursively nested pretty deeply, depending on the complexity of the roll equation. Depending on the roll type, you might have to go deeper into the object. Check out the libInline script for an example of parsing a roll and arriving at the display roll tip.
Thanks! that was just what I needed. It worked like a charm. 
1631814713
timmaugh
Forum Champion
API Scripter
Great! Glad to help!