Difference between revisions of "Template:Iconbar"

m (1 revision)
 
(Replaced content with "<includeonly>{{#invoke: iconbar | bar | min = {{{total|}}} }}</includeonly><noinclude> {{Documentation}} <!-- Put categories/interwiki on the documentation page --> </noin...")
 
Line 1: Line 1:
<includeonly>{{
+
<includeonly>{{#invoke: iconbar | bar | min = {{{total|}}} }}</includeonly><noinclude>
  #if: {{{value|}}}
+
{{Documentation}}
  | {{
+
<!-- Put categories/interwiki on the documentation page -->
    #iferror: {{ #expr: {{{value}}} }}
+
</noinclude>
    | <strong class="error">Error: the value must be a number!</strong><!-- any ideas for a better error message? -->
 
    | <span class="nowrap" title="{{ #if: {{{title|}}} | {{{title}}} | {{ #expr: floor( abs( {{{value}}} ) ) }} }}">{{
 
      #ifeq: {{ #expr: floor( abs( {{{value}}} ) ) }} | 0<!-- empty bar -->
 
      | {{
 
        #if: {{{empty|}}}
 
        | [[File:{{{empty}}}{{ #if: {{{size|}}} | {{!}}{{{size}}}{{ #iferror: {{ #expr: {{{size}}} }} || px }} }}]]
 
      }}
 
      | {{
 
        #if: {{{reverse|}}}<!-- reversed bar, if we have an odd number of units -->
 
        | {{
 
          #iferror: {{ #expr: {{{total}}} }} || {{
 
            #ifexpr: {{{total}}} - {{{value}}} >= 1 | {{
 
              padright:
 
              | {{
 
                #expr: floor( abs( {{{total}}} - {{{value}}} ) / 2 ) * {{ #len: [[File:{{{empty}}}{{ #if: {{{size|}}} | {{!}}{{{size}}}{{ #iferror: {{ #expr: {{{size}}} }} || px }} }}]] }}
 
              }}
 
              | [[File:{{{empty}}}{{ #if: {{{size|}}} | {{!}}{{{size}}}{{ #iferror: {{ #expr: {{{size}}} }} || px }} }}]]
 
            }}
 
          }}
 
        }}{{
 
          #ifexpr: floor( abs( {{{value}}} ) ) mod 2 = 1
 
          | [[File:{{{half}}}{{ #if: {{{size|}}} | {{!}}{{{size}}}{{ #iferror: {{ #expr: {{{size}}} }} || px }} }}]]
 
        }}
 
      }}{{<!--
 
              here be magic
 
              attribution: this is adapted from [[wikia:c:yugioh:Template:Repeat]] (a concept by others that I spun out and perfected =D )
 
        -->
 
        padleft:
 
        | {{
 
          #expr: floor( abs( {{{value}}} ) / 2 ) * {{ #len: [[File:{{{full}}}{{ #if: {{{size|}}} | {{!}}{{{size}}}{{ #iferror: {{ #expr: {{{size}}} }} || px }} }}]] }}
 
        }}
 
        | [[File:{{{full}}}{{ #if: {{{size|}}} | {{!}}{{{size}}}{{ #iferror: {{ #expr: {{{size}}} }} || px }} }}]]
 
      }}{{
 
        #if: {{{reverse|}}}<!-- non-reversed bar, if we have an odd number of units -->
 
        || {{
 
          #ifexpr: floor( abs( {{{value}}} ) ) mod 2 = 1
 
          | [[File:{{{half}}}{{ #if: {{{size|}}} | {{!}}{{{size}}}{{ #iferror: {{ #expr: {{{size}}} }} || px }} }}]]
 
        }}{{
 
          #iferror: {{ #expr: {{{total}}} }} || {{
 
            #ifexpr: {{{total}}} - {{{value}}} >= 1 | {{
 
              padleft:
 
              | {{
 
                #expr: floor( abs( {{{total}}} - {{{value}}} ) / 2 ) * {{ #len: [[File:{{{empty}}}{{ #if: {{{size|}}} | {{!}}{{{size}}}{{ #iferror: {{ #expr: {{{size}}} }} || px }} }}]] }}
 
              }}
 
              | [[File:{{{empty}}}{{ #if: {{{size|}}} | {{!}}{{{size}}}{{ #iferror: {{ #expr: {{{size}}} }} || px }} }}]]
 
            }}
 
          }}
 
        }}
 
      }}
 
    }}</span>
 
  }}
 
  | [[File:{{{empty}}}{{ #if: {{{size|}}} | {{!}}{{{size}}}{{ #iferror: {{ #expr: {{{size}}} }} || px }} }}]]
 
}}</includeonly><noinclude>
 
{{/doc}}
 
 
 
[[Category:Image templates|I]]
 

Latest revision as of 13:33, 3 August 2015

[view | edit | history | purge]Documentation
This template uses Module:Iconbar, a script written in Lua.
Please see wp:Lua and mw:Extension:Scribunto to learn more.

This template creates a bar made of icons.

{{iconbar
|value=
|title=
|size=
|full=
|half=
|empty=
|reverse=
|total=
}}
Parameter Function Default value
value Integer value between 0 and 20. One "full" icon is shown for each increase of 2 to value (e.g. three are shown if value is 6 or 7, etc.), and if value is odd, a "half" icon is shown at the end of the bar. 0
title Mouseover text. If this parameter isn't specified, it falls back to value. None
size Width of each icon in CSS units like "px" or "em". Units default to "px". None
full "Full" icon. One of these is shown for each increase of 2 to value (e.g. three are shown if value is 6 or 7, etc.). None
half "Half" icon, used at the end of the bar if value is odd. None
empty "Empty" icon, used if value is 0 or if total is used and is higher than value. None
reverse Pass a value to display the "half" icon on the left end of the bar instead of the right.
total Minimum number of icons to be shown. If value is lower than this, empty icons are shown to reach the minimum. None

See also

[view | edit | history | purge]The above documentation is transcluded from Template:Iconbar/doc.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Need wiki hosting?

Do you need a wiki for your Minecraft mod/gaming wiki? We'll host it for free! Contact us.

Other wikis

Indie-game wikis
Powered by Indie Wikis
Looking for a server?

Join Techworld - an amazing custom modpack server.