Template:Item

From Starlight River 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 Lua and Extension:Scribunto to learn more about Lua.
This template is i18n-ready, which means it is easy to localize for different languages. Please see I18n & l10n for Templates to learn more.

This template adds rows to the table "Imageinfo", which is declared by the template Image. View table.

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}}
  • htmltable(Preferred) or html-2-cell is similar to table, but will produce a result suitable for html tables instead of mediawiki tables (roughly a shortcut for {{item|mode=image|itemname}} </td><td> {{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 seperate filenames with slashes(eg. Diverman.png/Soul Forge (placed).png).

size

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

You can specify multiple sizes, just seperated 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
Vitric ShardVitric Shard {{item|Vitric Shard}} Basic usage.
Vitric ShardStar Powder {{item|Vitric Shard|Vitric Spike}} Custom text.
Vitric ShardVitric Shards Exotic GeodeExotic Geodes {{item|Vitric Shard|s}} {{item|Exotic Geode|s}} Plural.
GlassweaverGlassweaver {{item|Glassweaver|size=32px}} Custom image size. (Read Extended image syntax for details).
GlassweaverHive
Mind
{{item|Glassweaver|size=32px|Glass<br/>weaver}} Custom text in multiple lines.
Treasure BagTreasure Bags {{item|Treasure Bag|s|ext=gif}} Custom image file extension.
Treasure BagTreasure Bags(Expert Mode) {{item|Treasure Bag|s|note=(Expert Mode)|ext=gif}} Note text.
Shield ConstructShield Fighter {{item|Shield Construct|image=Shield Construct.png|Shield Fighter}} Custom image file name.
Shield ConstructShield Fighter {{item|Shield Construct|image=Shield Construct.png|Shield Fighter|ext=jpg}} Will display Shield Construct.png, ext is ignored when image is specified.
Shield ConstructShield Fighter {{item|Shield Construct|link=Shield Construct|Shield Fighter}} Custom link target.
Vitric ShardVitric Shard {{item|Vitric Shard|link=}} Unlinked.
Vitric ShardVitric Shard {{item|Vitric Shard|nolink=y}} Unlinked.
Vitric ShardVitric Shard {{item|Vitric Shard|nolink=y|link=Astral Bar}} if link is specified, it will override unlink=y.
Vitric ShardVitric Shard
{{item|Vitric Shard|anchor=y}} Create an anchor. Now {{PAGENAME}}#Vitric Shard will link to here.

Multiple images

Result Code Note
Vitric ForgeheartVitric ForgeheartVitric Forgeheart {{item|Vitric Forgeheart|image=Vitric Forgeheart.png/Vitric Forgeheart_(placed).png}} Multiple images with auto size.
Vitric ForgeheartVitric ForgeheartVitric Forgeheart {{item|Vitric Forgeheart|image=Vitric Forgeheart.png/Vitric Forgeheart_(placed).gif|size=20px}} Only one size specified, all images will use this size.
Vitric ForgeheartVitric ForgeheartVitric Forgeheart {{item|Vitric Forgeheart|image=Vitric Forgeheart.png/Vitric Forgeheart_(placed).gif|size=30px/20px}} Multiple images with multiple sizes.
Vitric ForgeheartVitric ForgeheartVitric Forgeheart {{item|Vitric Forgeheart|image=Vitric Forgeheart.png/Vitric Forgeheart_(placed).gif|size=30px/20px/300px}} Size is more than images, extra size is ignored.
Vitric ForgeheartVitric ForgeheartVitric ForgeheartVitric Forgeheart {{item|Vitric Forgeheart|image=Vitric Forgeheart.png/Vitric Forgeheart_(placed).gif/Starlight Waters.png|size=16px/50px}} Size is less than image, extra image will use auto size.

Wrap and note2

wrap is valid only when note2 is not specified.

Result Code Note
Vitric ShardVitric Shard(some note) {{item|Vitric Shard|wrap=y|note=(some note)}} If there is a note, note will display on next line.
Vitric ShardVitric Shard
some other notes.
{{item|Vitric Shard|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
Vitric ShardVitric Shard {{item|Vitric Shard}} By default, it will display image and text info.
Vitric Shard {{item|Vitric Shard|mode=image}} mode=image: Only image will be displayed, no text, no note.
Vitric Shard(some note) {{item|Vitric Shard|mode=text|wrap=y|note=(some note)}} mode=text: image won't be displayed.
Vitric Shard Vitric Shard
Exotic Geode Exotic Geodes(some note)
{| class="wikitable"
|{{item|Vitric Shard|mode=table}}
|-
|{{item|Exotic Geode|s|note=(some note)|mode=table}}
|}
mode=table: output as two adjacent cells for table.

Css and predefined classes

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

Vitric ShardVitric Shardnote
note2

Vitric ShardVitric Shardnote
note2
{{item|Vitric Shard|note=note|note2=note2|class=notecolor}}
{{item|Vitric Shard|note=note|note2=note2|class=note2color}}
{{item|Vitric Shard|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 .
Vitric ShardVitric Shardnote
note2

Vitric ShardVitric Shardnote
note2
{{item|Vitric Shard|note=note|note2=note2|class=notecolor}}
{{item|Vitric Shard|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.
Vitric ShardVitric Shardnote
note2

Vitric ShardVitric Shardnote
note2

Vitric ShardVitric Shardnote
note2
{{item|Vitric Shard|note=note|note2=note2|class=left}}<br/>{{item|Vitric Shard|note=note|note2=note2|class=center}}<br/>{{item|Vitric Shard|note=note|note2=note2|class=right}} Predefined class: alignleft, aligncenter, and alignright, text-align = left, center, or right, respectively.
Vitric ShardVitric Shardnote
note2

Vitric ShardVitric Shardnote
note2

Vitric ShardVitric Shardnote
note2
{{item|Vitric Shard|note=note|note2=note2|class=textleft}}<br/>{{item|Vitric Shard|note=note|note2=note2|class=textcenter}}<br/>{{item|Vitric Shard|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.
Vitric Shard {{item|Vitric Shard|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.
Vitric ShardVitric Shardnote
note2
{{item|Vitric Shard|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|Vitric Shard|note=(note)}}

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

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

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

{{item|Vitric Shard|note=(note)|link=Astral 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|Vitric Shard|note=(note)}}

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

reset all:
{{item/options|resetall}}
{{item|Vitric Shard|note=(note)}}

By default:

Vitric ShardVitric Shard(note)

turn on line wrap, and set to text mode:

Vitric Shard(note)

turn on no link mode:

Vitric Shard(note)

This will be overrid by link=

Vitric Shard(note)

get current setting:

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

reset all options:

Vitric ShardVitric Shard(note)

custom css and class:

Vitric ShardVitric Shard(note)

Vitric ShardVitric Shard(note)

reset all:

Vitric ShardVitric Shard(note)