Ad placeholder

User:NtCarlson/Template:Damage dice image: Difference between revisions

Jump to navigation Jump to search
Use {{trim}} to better format the source code with newlines without affecting the output
(Updated documentation)
(Use {{trim}} to better format the source code with newlines without affecting the output)
 
Line 1: Line 1:
<includeonly><!--
<includeonly>{{trim|
Width specifies the size of the dice rather than the size of the entire element
<!-- Width specifies the size of the dice rather than the size of the entire element -->
-->{{#lvardef: width | {{{width|30px}}}}}<!--
{{#lvardef: width | {{{width|30px}}}}}
Get the number of dice needed to compute the size of the element
 
-->{{#lvardef: n_dice | 0}}{{#while:  
<!-- Get the number of dice needed to compute the size of the element -->
{{#lvardef: n_dice | 0}}
{{#while:  
| {{{ {{#expr: {{#lvar: n_dice }} + 1}} |}}}
| {{{ {{#expr: {{#lvar: n_dice }} + 1}} |}}}
| {{#lvardef: n_dice | {{#expr: {{#lvar: n_dice }} + 1 }} }}
| {{#lvardef: n_dice | {{#expr: {{#lvar: n_dice }} + 1 }} }}
}}{{#lvardef: elem_width | {{#ifexpr: {{#lvar: n_dice}} >= 2
}}
 
<!-- Compute size of element based on number of dice. There probably is a better way to do this. -->
{{#lvardef: elem_width | {{#ifexpr: {{#lvar: n_dice}} >= 2
   | calc({{#lvar: width}} * 1.4)
   | calc({{#lvar: width}} * 1.4)
   | {{#lvar: width}}
   | {{#lvar: width}}
}}}}<!--
}}}}
Compute size of element based on number of dice. There probably is a better way to do this.
{{#lvardef: left_padding | {{#ifexpr: {{#lvar: n_dice}} >= 3
-->{{#lvardef: left_padding | {{#ifexpr: {{#lvar: n_dice}} >= 3
   | calc({{#lvar: width}} * 0.4)
   | calc({{#lvar: width}} * 0.4)
   | 0
   | 0
}}}}{{#lvardef: top_padding | {{#switch: {{#lvar: n_dice}}
}}}}
{{#lvardef: top_padding | {{#switch: {{#lvar: n_dice}}
   | 1 = 0
   | 1 = 0
   | 2 | 3 = calc({{#lvar: width}} * 0.3)
   | 2 | 3 = calc({{#lvar: width}} * 0.3)
   | 4 | 5 = calc({{#lvar: width}} * 0.7)
   | 4 | 5 = calc({{#lvar: width}} * 0.7)
}}}}<!--
}}}}
}}<!--
Container element
Container element
--><span style="
--><span style="
Line 27: Line 33:
   padding-left: {{#lvar: left_padding}};
   padding-left: {{#lvar: left_padding}};
   padding-top:  {{#lvar: top_padding}};
   padding-top:  {{#lvar: top_padding}};
"><!--
">{{trim|
Display each die
<!-- Display each die -->
-->{{#lvardef: i | 1 }}{{#while:  
{{#lvardef: i | 1 }}
{{#while:  
| {{{{{#lvar: i }} |}}}
| {{{{{#lvar: i }} |}}}
|
|
Line 41: Line 48:
| 5 = translate(-40%, -68%) rotate(40deg)
| 5 = translate(-40%, -68%) rotate(40deg)
}}}}
}}}}
<span style="
<span style="
     z-index: {{#expr: {{#lvar: n_dice}} - {{#lvar: i}}}};
     z-index: {{#expr: {{#lvar: n_dice}} - {{#lvar: i}}}};
Line 46: Line 54:
     transform: {{#lvar: transform}}
     transform: {{#lvar: transform}}
">[[File:{{#lvar: die}} {{#lvar:type}}.png|link= |x{{#lvar: width}}]]</span>
">[[File:{{#lvar: die}} {{#lvar:type}}.png|link= |x{{#lvar: width}}]]</span>
{{#lvardef: i | {{#expr: {{#lvar: i }} + 1 }} }}
{{#lvardef: i | {{#expr: {{#lvar: i }} + 1 }} }}
}}
}}</span></includeonly><noinclude>
}}</span></includeonly><noinclude>
[[File:Damage_dice_reference_image.png|thumb|right|Example of an in-game tooltip displaying damage dice.]]
[[File:Damage_dice_reference_image.png|thumb|right|Example of an in-game tooltip displaying damage dice.]]

Navigation menu