User:NtCarlson/Template:Damage dice image: Difference between revisions
Jump to navigation
Jump to search
(Parameter parsing) |
(Made size of element correctly adjust with dice size) |
||
Line 1: | Line 1: | ||
<includeonly>{{#lvardef: | <includeonly><!-- | ||
{{#while: | Width specifies the size of the dice rather than the size of the entire element | ||
-->{{#lvardef: width | {{{width|40}}}}}<!-- | |||
Get the number of dice needed to compute the size of the element | |||
-->{{#lvardef: n_dice | 0}}{{#while: | |||
| {{{ {{#expr: {{#lvar: n_dice }} + 1}} |}}} | |||
| {{#lvardef: n_dice | {{#expr: {{#lvar: n_dice }} + 1 }} }} | |||
}}{{#lvardef: elem_width | {{#ifexpr: {{#lvar: n_dice}} >= 2 | |||
| calc({{#lvar: width}} * 1.4) | |||
| {{#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 | |||
| calc({{#lvar: width}} * 0.4) | |||
| 0 | |||
}}}}{{#lvardef: top_padding | {{#switch: {{#lvar: n_dice}} | |||
| 1 = 0 | |||
| 2 | 3 = calc({{#lvar: width}} * 0.3) | |||
| 4 | 5 = calc({{#lvar: width}} * 0.7) | |||
}}}}<!-- | |||
Container element | |||
--><span style=" | |||
display: block; | |||
position: relative; | |||
width: {{#lvar: elem_width}}; | |||
height: {{#lvar: width}}; | |||
padding-left: {{#lvar: left_padding}}; | |||
padding-top: {{#lvar: top_padding}}; | |||
"><!-- | |||
Display each die | |||
-->{{#lvardef: i | 1 }}{{#while: | |||
| {{{{{#lvar: i }} |}}} | | {{{{{#lvar: i }} |}}} | ||
| | | | ||
{{#lvardef: die | {{#lvardef: die | {{ #explode: {{{{{#lvar: i }} |}}} |:|0}}}} | ||
{{#lvardef: type | {{ #explode: {{{{{#lvar: i }} |}}} |:|1}}}} | {{#lvardef: type | {{ #explode: {{{{{#lvar: i }} |}}} |:|1}}}} | ||
{{#lvardef: | {{#lvardef: transform | {{ #switch: {{#lvar: i }} | ||
| 1 = translate( | | 1 = translate( 0%, 0%) | ||
| 2 = translate( | | 2 = translate( 40%, -30%) rotate(20deg) | ||
| 3 = translate(- | | 3 = translate(-35%, -25%) rotate(40deg) | ||
| 4 = translate( | | 4 = translate( 40%, -70%) rotate(25deg) | ||
| 5 = translate(- | | 5 = translate(-40%, -68%) rotate(40deg) | ||
}}}} | }}}} | ||
<span style="z-index: -{{#lvar: i}}; position: absolute; transform: {{#lvar: | <span style=" | ||
z-index: -{{#lvar: i}}; | |||
position: absolute; | |||
transform: {{#lvar: transform}} | |||
">[[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> | {{User:NtCarlson/Template:Damage dice image|width=60px|d6:Fire|d4:Radiant|d8:Physical|d12:Lightning|d4:Psychic}} test | ||
{{User:NtCarlson/Template:Damage dice image|d6:Fire|d4:Radiant|d8:Physical|d12:Lightning}} test | {{User:NtCarlson/Template:Damage dice image|width=30px|d12:Physical|d4:Fire}} test | ||
</noinclude> | </noinclude> |
Revision as of 19:25, 18 December 2024
test test