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

A question about Custom Rolltemplates

1516396117
Missingquery
Pro
Sheet Author
API Scripter
Is it possible to implement something like custom roll templates for custom API commands? I have a macro that calls a custom API command, would it be possible to pass the results of the custom script into a html-customizable message template? Right now, I just have the script display the results as a chat message.
You can use the API to encapsulate your chat message in HTML/CSS styling for the chat window. Through this you can make it look  like a roll template, but it would not have the same functionality that a roll template would. You can also send the message as a roll template if it is available from the character sheet for the game.
For an example on using HTML/CSS with API output to chat, I highly recommend  Kristy's Faerun Calendar script as she does an excellent job of formatting her menu this way.
1516396684
Missingquery
Pro
Sheet Author
API Scripter
I would have to style messages using inline css, correct? Or is there a more convenient way (such as importing a css sheet from elsewhere)?
Inline unfortunately, which is why I like Kristy's approach of defining each inline css style as an object that you then call when building the HTML. The only thing I would change is to put the css objects inside of an overall object like so var CSS = { table: 'style="text-align:center;"'; }; Then you would use CSS.table inside of the HTML string.
1516398252

Edited 1516398309
Kirsty
Pro
Sheet Author
@Kyle G. Hey thanks! I can't take the credit though, I totally stole the template from Steve K.'s OGL sheet and used DXWarlock's Health colours script as an example of how to implement it. EDIT: Just saw your post. Idea stolen. ;) @Marth Lowell Yes, you have to use inline css. It's a bit of a pain, but what I've seen others do (and stolen the idea myself) is to make the css a variable within your function. That way when you make a change, it almost acts like a separate css sheet - you only have to make the change in one place. An example: var divstyle = 'style="width: 189px; border: 1px solid black; background-color: #ffffff; padding: 5px; font-size: 12px;"'; sendChat('Test', '<div ' + divstyle + '>My fancy div</div>';