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

Override/replace roll template color

1462773459

Edited 1462778977
DXWarlock
Sheet Author
API Scripter
I'm trying to work out a way to replace the color parts of the roll template with one of the roll template variables, but having no luck. All my roll templates are exactly the same other than the subheader color, so instead of making 10 roll templates with just the " background-color: " changed, I was attempting to pass the color in the roll itself. So for example I send this: &{template:RIFTS} {{color=white}} {{name=TestHeader}} {{subheader=Testsub}} {{TestRoll=[[1d20]]}} The css it triggers for subheader: .sheet-rolltemplate-RIFTS .sheet-subheader { background-color: #FCBA56; color: #000000; font-family:"Helvetica Neue",Helvetica,sans-serif; font-size:0.9em;     font-weight:bold;   text-align: center; padding-bottom: 5px;     border-top: 1px solid #000;     border-bottom: 1px solid #000; } All is fine and well, it works like it should, making the table/cell color what the css calls. But I try to do something like this, to replace the color it uses via the {{color}} called in the macro: <tr><td class="sheet-subheader" style="background-color:{{color}}">{{subheader}}</td></tr> It doesn't replace it the color. I'm not sure if what I'm trying to do is possible, as it seems the roll templates update in the chat archives to whatever it currently is (IE: you change the template, the chat archive shown of the old rolls that used it changes also). So a dynamic color might not be viable? Is there a way to pass variables I can call in the HTML or CSS with the macro to set colors, vs making 10 Roll templates that are the same with just different colors set for the background?
1462785945
Kryx
Pro
Sheet Author
API Scripter
Inline styling should win out via specificity of CSS. However inline styles are not recommended. It may also be the cause of the issue (no idea). I'd recommend setting a class instead. <tr><td class="sheet-subheader sheet-{{color}}">{{subheader}}</td></tr> Though that would limit your color options to the ones you define in CSS. If you invite me to a game with the issue I can look further.
1462786663
DXWarlock
Sheet Author
API Scripter
I actually JUST found that poking around in your 5e sheet :) and stole  .. borrowed... some of the template code for colors. I managed to get this: Using the same way of {{green=1}} (like the 5e sheet uses {{action=1}}) and so on and defining the class. Its a great start, but was trying to find a way to using the players color in the template since I have it pulled in the API and was trying to pass it over :\
1462786779

Edited 1462786820
Kryx
Pro
Sheet Author
API Scripter
Ah, then in that case inline styles are your best option. Perhaps invite me to the game so I can see the problem directly? It's hard to determine what is going on with css without looking at it in the browser. And you're free to steal as much as you want. :) Though "World" is fairly hard to read. I'd suggest either a lighter text color (an off white). Or altering the background to have it be readable.
1462786882
DXWarlock
Sheet Author
API Scripter
Sure Id be happy to if you dont mind wasting the time to look.
1462805456

Edited 1462805531
chris b.
Pro
Sheet Author
API Scripter
IIRC there is a set number of choices, right? if so, you may have to pre-define all the possible choices in your CSS, then in the API just set a variable to that color which is used for your class name. For instance, if you look at Pathfinder sheet, we have a dropdown of pre-defined colors with the color names as the values. Then we have css classes for each of those colors. this would be the value you'd set in the API to the same as the color the user picked for their avatar:  <select title="@{rolltemplate_color}" name="attr_rolltemplate_color" > <option value="black" selected>Black</option> <option value="white">white</option> <option value="grey">grey</option> <option value="darkgrey">darkgrey</option> ... </select> and in css: .sheet-rolltemplate-pf_generic {background-color:#000000;} .sheet-rolltemplate-pf_generic .sheet-color-green {background-color:#00FF00;} .sheet-rolltemplate-pf_generic .sheet-color-black {background-color:#000000;} .sheet-rolltemplate-pf_generic .sheet-color-red {background-color:#FF0000;} etc
1462824151

Edited 1462824359
DXWarlock
Sheet Author
API Scripter
That's what I ended up doing. Kryx looked at it with me. It seems dynamically trying to set a color in the template via a {{color=something}} template variable isnt possible. Reason I wanted it was I was trying to: Color code player rolls to their player color as the roll template header background color (or let people pick any color they want to use, say they want to send a roll with the title color #F13AAA with {{color=#F13AAA}}. In my weather script, set the background color of the weather messages to a color generated from a spectrum based on time of day and weather type (orange for dusk, dark blue for night, hazy grey for morning with rain, sky blue for clear mornings..etc) For the weather I could just add dozens of class colors in the CSS to cover all the combinations I would need I suppose. For players, I could set them up in the CSS to match what the players are using for the player rolls, but if a player changes their Roll20 color I will need to manually change the CSS.