Template:Item

From Thorium Mod Wiki
Jump to navigation Jump to search
Lua.svg
This template uses Module:Item, a script written in the Lua programming language. Please see wikipedia:Lua and mw:Extension:Scribunto to learn more about Lua.
Template-info.svg Documentation The documentation below is transcluded from Template:Item/doc. (edit | history)

An all-in-one template for display item name/icon/link.

By default, displays a link to the item and adds an item icon in front of it.

Usage

All parameters are optional. Despite this, some combinations are invalid and may cause errors.

See examples below for more details.

unnamed parameter 1

Default item display name, link target, and image file name.

unnamed Parameter 2

Custom link text, which can include line breaks (<br />) and other wikitext. If an 's', 'es', 'ies' or 'ves' is passed as the custom text, it will be appended to the end of the item name.

mode

Display mode. It can be:

  • image(Preferred) or imageonly or onlyimage means only image will be displayed;
  • text(Preferred) or noimage means no image will be displayed;
  • table(Preferred) or 2-cell will output 2 cells code for table. This is roughly a shortcut for {{item|mode=image|itemname}} || {{item|mode=text|itemname}}

Use preferred values as much as possible to get the best performance.

image

image filename, no brackets nor "File:"(must include file extension, eg. Diverman.png).

You can specify multiple images, just separate filenames with slashes(eg. Diverman.png/Soul Forge (placed).gif).

size

Custom graphic size (Read Extended image syntax for details).

You can specify multiple sizes, just separated with slashes(eg. 32px/24x24px).

When multiple images specified:

    • If only one size specified, it will apply to all images
    • if size is less then image, extra images will be displayed as if they don't have size argument
    • if size is more then image, extra sizes will simply be ignored.
ext

image file extension, default is png. Only valid when there is no image input.

link

Custom link target. If blank given(i.e. |link=|), it will be no link(See example below).

nolink = y/yes

Same as |link=|, only valid when there is no link input. If you use |link=somelink|nolink=y, it will be ignored.

anchor = y/yes

If set, will create an anchor for {{{1}}}.

note

Extra note text. By default, it will displayed as smaller and gray text between item name and platform icons , and without link on it.

note2

Another note text. By default, it will displayed as gray txt in normal size, without link, and always take a single line.

wrap = y/yes

Only valid when there is no note2= input. If set, note will be displayed in new line.

class

Custom Css class(es). There're some predefined classes for certain formatting purpose(see examples below). You can add yours if needed.

css or style

Custom css style rules.

Examples

Basic

Result Code Note
Thorium Ore.pngThorium Ore {{item|Thorium Ore}} Basic usage.
Thorium Ore.pngThorium {{item|Thorium Ore|Thorium}} Custom text.
Thorium Ore.pngThorium Ores {{item|Thorium Ore|s}} Plural.
Star Scouter.pngStar Scouter {{item|Star Scouter|size=32px}} Custom image size. (Read Extended image syntax for details).
Star Scouter.pngStar
Scouter
{{item|Star Scouter|size=32px|Star<br/>Scouter}} Custom text in multiple lines.
Treasure Bag.gifTreasure Bags {{item|Treasure Bag|s|ext=gif}} Custom image file extension.
Treasure Bag.gifTreasure Bags(Expert Mode) {{item|Treasure Bag|s|note={{small|(Expert Mode)}}|ext=gif}} Note text.
Diverman.pngDiverman Sam {{item|Diverman|image=Diverman.png|Diverman Sam}} Custom image file name.
Diverman.pngDiverman Sam {{item|Diverman|image=Diverman.png|Diverman Sam|ext=jpg}} Will display Diverman.png, ext is ignored when image is specified.
Diverman.pngDiverman Sam {{item|Diverman|link=Diverman|Diverman Sam}} Custom link target.
Thorium Ore.pngThorium Ore {{item|Thorium Ore|link=}} Unlinked.
Thorium Ore.pngThorium Ore {{item|Thorium Ore|nolink=y}} Unlinked.
Thorium Ore.pngThorium Ore {{item|Thorium Ore|nolink=y|link=Thorium Bar}} if link is specified, it will override unlink=y.
Thorium Ore.pngThorium Ore
{{item|Thorium Ore|anchor}} Create an anchor. Now {{PAGENAME}}#Thorium Ore will link to here.

Multiple images

Result Code Note
Soul Forge.pngSoul Forge (placed).gifSoul Forge {{item|Soul Forge|image=Soul Forge.png/Soul Forge (placed).gif}} Multiple images with auto size.
Soul Forge.pngSoul Forge (placed).gifSoul Forge {{item|Soul Forge|image=Soul Forge.png/Soul Forge (placed).gif|size=20px}} Only one size specified, all images will use this size.
Soul Forge.pngSoul Forge (placed).gifSoul Forge {{item|Soul Forge|image=Soul Forge.png/Soul Forge (placed).gif|size=30px/20px}} Multiple images with multiple sizes.
Soul Forge.pngSoul Forge (placed).gifSoul Forge {{item|Soul Forge|image=Soul Forge.png/Soul Forge (placed).gif|size=30px/20px/300px}} Size is more them images, extra size is ignored.
Soul Forge.pngSoul Forge (placed).gifArcane Armor Fabricator.pngSoul Forge {{item|Soul Forge|image=Soul Forge.png/Soul Forge (placed).gif/Arcane Armor Fabricator.png|size=16px/40px}} Size is less then image, extra image will use auto size.

Wrap and note2

wrap is valid only when note2 is not specified.

Result Code Note
Thorium Ore.pngThorium Ore(some note) {{item|Thorium Ore|wrap=y|note=(some note)}} If there is a note, note will display on next line.
Thorium Ore.pngThorium Ore
some other notes.
{{item|Thorium Ore|wrap=y|note2=some other notes.}} If note2 is specified, note will be displayed on the same line, even if wrap=y.

Display mode

Result Code Note
Thorium Ore.pngThorium Ore {{item|Thorium Ore}} By default, it will display image and text info.
Thorium Ore.png {{item|Thorium Ore|mode=image}} mode=image: Only image will be displayed, no text, no note.
Thorium Ore(some note) {{item|Thorium Ore|mode=text|wrap=y|note=(some note)}} mode=text: image won't be displayed.
Thorium Ore.png Thorium Ore
Butterfly Staff.png Butterfly Staff(some note)
{| class="wikitable"
|{{item|Thorium Ore|mode=table}}
|-
|{{item|Butterfly Staff|note=(some note)|mode=table}}
|}
mode=table: output as two adjacent cells for table.

Css and predefined classes

Result Code Note
Thorium Ore.pngThorium Ore {{item|Thorium Ore|link=|css=color:red;border: 2px solid blue;padding: 3px; background:#ccc}} Custom css rules.
Thorium Ore.pngThorium Ore {{item|Thorium Ore|class=boldname}} Predefined class: boldname, item name will displayed in bold.
Thorium Ore.pngThorium Orenote
note2

Thorium Ore.pngThorium Orenote
note2

Thorium Ore.pngThorium Orenote
note2
{{item|Thorium Ore|note=note|note2=note2|class=notecolor}}
{{item|Thorium Ore|note=note|note2=note2|class=note2color}}
{{item|Thorium Ore|note=note|note2=note2|css=color:red|class=note2color}}
Predefined class: notecolor and note2color, note or note2 will display in normal(inherited) text color, respectively .
Thorium Ore.pngThorium Orenote
note2

Thorium Ore.pngThorium Orenote
note2
{{item|Thorium Ore|note=note|note2=note2|class=notecolor}}
{{item|Thorium Ore|note=note|note2=note2|class=note2color}}
Predefined class: notesize and note2size, note will display in normal size, or note2 will display in reduced size, respectively.
Thorium Ore.pngThorium Orenote
note2

Thorium Ore.pngThorium Orenote
note2

Thorium Ore.pngThorium Orenote
note2
{{item|Thorium Ore|note=note|note2=note2|class=left}}<br/>{{item|Thorium Ore|note=note|note2=note2|class=center}}<br/>{{item|Thorium Ore|note=note|note2=note2|class=right}} Predefined class: alignleft, aligncenter, and alignright, text-align = left, center, or right, respectively.
Thorium Ore.pngThorium Orenote
note2

Thorium Ore.pngThorium Orenote
note2

Thorium Ore.pngThorium Orenote
note2
{{item|Thorium Ore|note=note|note2=note2|class=textleft}}<br/>{{item|Thorium Ore|note=note|note2=note2|class=textcenter}}<br/>{{item|Thorium Ore|note=note|note2=note2|class=textright}} Predefined class: textleft, textcenter, and textright, Similar to alignleft/aligncenter/alignright, but only applied to text part.alignleft/center/right can use with text/align/center/right at same time.
Thorium Ore {{item|Thorium Ore|class=block|mode=text}} Predefined class: block, main item element and text element will display as block element(default is inline-block).It is usually only practical when mode=text.
Thorium Ore.pngThorium Orenote
note2
{{item|Thorium Ore|note=note|note2=note2|class=notesize notecolor boldname|css=color:red}} You can specify multiple classes, seperate with space, and can specify custom css rules at the same time.

Change default options

You can use {{item/options}} to set/get and reset some options' default value.

Usage

  • Set: {{item/options|nolink=y|...}} or {{item/options|set|nolink=y|...}}
  • get: {{item/options|get|nolink}}
  • reset: {{item/options|reset}} or {{item/options|resetall}}
NOTE: In order to avoid unwanted influences, it is very important to reset options as soon as possible. Especially in the template, you should reset options before the template ends.

All parameters:

unnamed parameter 1

Action. get or load means get the current value of a option, reset or resetall means reset all options to default value, other values(include none. if you want, recommend to use set for better readability) means set options' value.

unnamed Parameter 2

The name of option which you want to get its value, only valid when action is get. Can be mode, wrap, nolink, class, css or style.

mode

Only valid when action is set. Set the default value for {{item}}'s mode parameter. You can use any valid value for {{item}}'s mode parameter, and a invalid value(recommend to use default, all, or both for better readability) means change the mode back to default. See {{item}}'s mode parameter.

wrap = y/yes/n/no

Only valid when action is set. Turn on/off line wrap. See {{item}}'s wrap parameter.

anchor = y/yes/n/no

Only valid when action is set. Turn on/off anchor. See {{item}}'s anchor parameter.

nolink = y/yes/n/no

Only valid when action is set. Turn on/off no link option. See {{item}}'s nolink parameter.

class

Only valid when action is set. Default value for class. See {{item}}'s class parameter.

css/style

Only valid when action is set. Default value for css. See {{item}}'s css parameter.

See examples below for more details.

Example

Code output
By default: 

{{item|Thorium Ore|note=(note)}}

turn on line wrap, and set to text mode: 
{{item/options|set|wrap=y|mode=text}}
{{item|Thorium Ore|note=(note)}}

turn on no link mode: 
{{item/options|set|nolink=y}}
{{item|Thorium Ore|note=(note)}}

This will be overrid by '''<code>link=</code>'''

{{item|Thorium Ore|note=(note)|link=Thorium Bar}}

get current setting:

nolink = {{item/options|get|nolink}} ; 
wrap = {{item/options|get|wrap}} ;
mode = {{item/options|get|mode}} ;

reset all options: 
{{item/options|reset}}
{{item|Thorium Ore|note=(note)}}

custom css and class:
{{item/options|set|css=border:1px solid red;padding:3px}}
{{item|Thorium Ore|note=(note)}}
{{item/options|set|class=boldname}}
{{item|Thorium Ore|note=(note)}}

reset all:
{{item/options|resetall}}
{{item|Thorium Ore|note=(note)}}

By default:

Thorium Ore.pngThorium Ore(note)

turn on line wrap, and set to text mode:

Thorium Ore(note)

turn on no link mode:

Thorium Ore(note)

This will be overrid by link=

Thorium Ore(note)

get current setting:

nolink = y ; wrap = y ; mode = text ;

reset all options:

Thorium Ore.pngThorium Ore(note)

custom css and class:

Thorium Ore.pngThorium Ore(note)

Thorium Ore.pngThorium Ore(note)

reset all:

Thorium Ore.pngThorium Ore(note)