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

From bg3.wiki
Jump to navigation Jump to search
(Prototype of damage dice display that replicates how the game displays it)
 
(Use {{trim}} to better format the source code with newlines without affecting the output)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><span style="display: block; width: 60px; height: 60px; padding-left: 40px; padding-top: 40px; position: relative">
<includeonly>{{trim|
<span style="z-index: 0; position: absolute">[[File:d8 Physical.png]]</span>
<!-- Width specifies the size of the dice rather than the size of the entire element -->
<span style="z-index:-1; position: absolute; transform: translate(40px, -20px) rotate(20deg)">[[File:d4 Fire.png]]</span>
{{#lvardef: width | {{{width|30px}}}}}
<span style="z-index:-2; position: absolute; transform: translate(-30px, -15px) rotate(40deg)">[[File:d8 Radiant.png]]</span>
 
<span style="z-index:-3; position: absolute; transform: translate(30px, -40px) rotate(25deg)">[[File:d6 Poison.png]]</span>
<!-- Get the number of dice needed to compute the size of the element -->
<span style="z-index:-4; position: absolute; transform: translate(-28px, -42px) rotate(45deg)">[[File:d4 Psychic.png]]</span>
{{#lvardef: n_dice | 0}}
</span></includeonly><noinclude>
{{#while:
{{User:NtCarlson/Template:Damage dice image}} test
| {{{ {{#expr: {{#lvar: n_dice }} + 1}} |}}}
| {{#lvardef: n_dice | {{#expr: {{#lvar: n_dice }} + 1 }} }}
}}
 
<!-- 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)
  | {{#lvar: width}}
}}}}
{{#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}};
">{{trim|
<!-- Display each die -->
{{#lvardef: i | 1 }}
{{#while:
| {{{{{#lvar: i }} |}}}
|
{{#lvardef: die      | {{ #explode: {{{{{#lvar: i }} |}}} |:|0}}}}
{{#lvardef: type      | {{ #explode: {{{{{#lvar: i }} |}}} |:|1}}}}
{{#lvardef: transform | {{ #switch: {{#lvar: i }}
| 1 = translate( 0%,  0%)
| 2 = translate( 40%, -30%) rotate(20deg)
| 3 = translate(-35%, -25%) rotate(40deg)
| 4 = translate( 40%, -70%) rotate(25deg)
| 5 = translate(-40%, -68%) rotate(40deg)
}}}}
 
<span style="
    z-index: {{#expr: {{#lvar: n_dice}} - {{#lvar: i}}}};
    position: absolute;
    transform: {{#lvar: transform}}
">[[File:{{#lvar: die}} {{#lvar:type}}.png|link= |x{{#lvar: width}}]]</span>
 
{{#lvardef: i | {{#expr: {{#lvar: i }} + 1 }} }}
}}
}}</span></includeonly><noinclude>
[[File:Damage_dice_reference_image.png|thumb|right|Example of an in-game tooltip displaying damage dice.]]
Replicates the damage dice display used in game.
{{clear}}
== Examples ==
{{Template demo
| style = table
| <nowiki>
{{User:NtCarlson/Template:Damage dice image|d12:Physical|d4:Fire}}
</nowiki>
| <nowiki>
{{User:NtCarlson/Template:Damage dice image
| width = 60px
| d8:Physical
| d4:Fire
| d4:Psychic
| d4:Psychic
| d8:Radiant
}}
</nowiki>
}}
</noinclude>
</noinclude>

Latest revision as of 21:34, 18 December 2024

Example of an in-game tooltip displaying damage dice.

Replicates the damage dice display used in game.

Examples[edit | edit source]

Markup Renders as
{{User:NtCarlson/Template:Damage dice image|d12:Physical|d4:Fire}}

D12 Physical.pngD4 Fire.png

{{User:NtCarlson/Template:Damage dice image
| width = 60px
| d8:Physical
| d4:Fire
| d4:Psychic
| d4:Psychic
| d8:Radiant
}}

D8 Physical.pngD4 Fire.pngD4 Psychic.pngD4 Psychic.pngD8 Radiant.png