Template:Resource link: Difference between revisions
(updated to match the new module method; will update doc next) |
(Rewriting doc to standard, new parameters, etc. set by building link) |
||
Line 4: | Line 4: | ||
}}</includeonly><noinclude> | }}</includeonly><noinclude> | ||
== Overview == | |||
Creates a link to the article for a resource (or good). | |||
[[Template:rl]] is a shortcut to this template. You can use <code><nowiki>{{bl}}</nowiki></code> instead of <code><nowiki>{{Building link}}</nowiki></code> with the same parameters. | |||
Use good judgment when writing paragraphs that feature a lot of resource links. The first mention should probably be done with this template. But you may find that paragraphs densely mentioning resources become harder not easier to read due to the icons and color fluctuations. After the first mention of the resource, it might be better for subsequent references to be in plain text or with this template but without an icon. | |||
== Parameters == | |||
=== Resource === | |||
The name of the resource (or good) is the only required parameter. Use the name as it appears in-game, including spaces. A missing or mispelled name will result in an error. | |||
= | If you do not wish to write the code <code><nowiki>name=</nowiki></code>, you may skip that, but you must specify the name of the resource before any other parameters. | ||
{|class=wikitable | |||
! Parameter !! Type !! Description | |||
|- | |||
| name || string || The name of the resource, as it appears in the game. | |||
|} | |||
== | === Output overrides === | ||
All of these parameters are optional and change how the link is formatted. | |||
{|class= | {|class=wikitable | ||
! Parameter !! Type !! Description | ! Parameter !! Type !! Description | ||
|- | |- | ||
| | | size || string || The size of the icon to display. Choose one of the following: | ||
* <code>none</code> | * <code>none</code> | ||
* <code>small</code> | * <code>small</code> | ||
* <code> | * <code>medium</code> | ||
* <code>large</code> | * <code>large</code> | ||
* <code>huge</code> | * <code>huge</code> | ||
< | The default for resources is <code>small</code>, suitable for paragraphs. | ||
|- | |||
| display || string || if you include <code>display=notext</code> only the icon will be rendered. There are currently no other options for this parameter. | |||
|} | |} | ||
Resource links that are written into paragraphs should use the small icon, which is the default, or no icon. The small icon size conforms to the standard line height of text on the wiki and will not disrupt the flow of text. | |||
Note that adding "s" after the template call no longer includes the "s" in the link as it used to. | |||
== Examples == | |||
=== Basic usage === | |||
<pre>{{Resource link|Biscuits}}</pre> | |||
Makes a link to the {{Resource link|Biscuits}} article with a small icon suitable for use in-line in paragraphs like this that discuss villagers and their needs for yummy food. Subsequent mention of Biscuits in the same paragraph can omit the link to avoid adding unnecessary color to paragraphs. | |||
' | <pre>{{Resource link|Biscuits|medium}}</pre> | ||
Yields an icon that's slightly larger for improved recognition. Suitable for tables that list lots of resources where layout provides some space for icons: | |||
{{Resource link|Biscuits|size=medium}} | |||
<pre>{{Resource link|name=Biscuits|large}}</pre> | |||
Yields a large icon for good recognition for use in tables with space that allows it: | |||
{{Resource link| | {{Resource link|name=Biscuits|large}} | ||
<pre>{{Resource link|Biscuits|size=huge}}</pre> | |||
Yields the largest icon, which is great for headlining tables featuring this resource: | |||
{{Resource link|Biscuits|size=huge}} | |||
=== Other examples === | |||
{{Resource link|Biscuits| | <pre>{{Resource link|Biscuits|size=none}}</pre> | ||
Alternatively, paragraphs can include even simpler links like {{Resource link|Biscuits|size=none}} that display no icon to improve the flow of the paragraph at the cost of a slight reduction in recognition since the resource icons are so ubiquitous in the game. The highlighting of the link is still sufficient to draw the reader's attention. No icon is advised for every link to a resource after its first (where an icon is appropriate) within each paragraph. | |||
Using no icon is also great for lists: | |||
* {{Resource link|Biscuits|size=none}} | |||
* {{Resource link|Jerky|size=none}} | |||
* {{Resource link|Pie|size=none}} | |||
<pre>{{Resource link|Jerky|size=gigantic}}</pre> | |||
Specifying an icon size that is not recognized does not return an error. Instead, it defaults to the small icon: | |||
{{Resource link| | {{Resource link|Jerky|size=gigantic}} | ||
=== Errors === | |||
The following are | The following are error messages generated by calling the template incorrectly. | ||
<pre>{{Resource link}}</pre> | |||
With no arguments: {{Resource link}} | |||
<pre>{{Resource link|Potatoes}}</pre> | |||
Naming a resource that doesn't exist in the game: {{Resource link|Potatoes}} | |||
{{Resource link| | <pre>{{Resource link|huge|Jerky}}</pre> | ||
The same goes for swapping the order of the parameters so that the resource is not first: {{Resource link|huge|Jerky}} | |||
[[Category:Lua-based templates]] | [[Category:Lua-based templates]] | ||
[[Category:Link templates]]</noinclude> | [[Category:Link templates]]</noinclude> |
Revision as of 03:10, 19 October 2024
Overview
Creates a link to the article for a resource (or good).
Template:rl is a shortcut to this template. You can use {{bl}}
instead of {{Building link}}
with the same parameters.
Use good judgment when writing paragraphs that feature a lot of resource links. The first mention should probably be done with this template. But you may find that paragraphs densely mentioning resources become harder not easier to read due to the icons and color fluctuations. After the first mention of the resource, it might be better for subsequent references to be in plain text or with this template but without an icon.
Parameters
Resource
The name of the resource (or good) is the only required parameter. Use the name as it appears in-game, including spaces. A missing or mispelled name will result in an error.
If you do not wish to write the code name=
, you may skip that, but you must specify the name of the resource before any other parameters.
Parameter | Type | Description |
---|---|---|
name | string | The name of the resource, as it appears in the game. |
Output overrides
All of these parameters are optional and change how the link is formatted.
Parameter | Type | Description |
---|---|---|
size | string | The size of the icon to display. Choose one of the following:
The default for resources is |
display | string | if you include display=notext only the icon will be rendered. There are currently no other options for this parameter.
|
Resource links that are written into paragraphs should use the small icon, which is the default, or no icon. The small icon size conforms to the standard line height of text on the wiki and will not disrupt the flow of text.
Note that adding "s" after the template call no longer includes the "s" in the link as it used to.
Examples
Basic usage
{{Resource link|Biscuits}}
Makes a link to the Biscuits article with a small icon suitable for use in-line in paragraphs like this that discuss villagers and their needs for yummy food. Subsequent mention of Biscuits in the same paragraph can omit the link to avoid adding unnecessary color to paragraphs.
{{Resource link|Biscuits|medium}}
Yields an icon that's slightly larger for improved recognition. Suitable for tables that list lots of resources where layout provides some space for icons:
{{Resource link|name=Biscuits|large}}
Yields a large icon for good recognition for use in tables with space that allows it:
{{Resource link|Biscuits|size=huge}}
Yields the largest icon, which is great for headlining tables featuring this resource:
Other examples
{{Resource link|Biscuits|size=none}}
Alternatively, paragraphs can include even simpler links like Biscuits that display no icon to improve the flow of the paragraph at the cost of a slight reduction in recognition since the resource icons are so ubiquitous in the game. The highlighting of the link is still sufficient to draw the reader's attention. No icon is advised for every link to a resource after its first (where an icon is appropriate) within each paragraph.
Using no icon is also great for lists:
{{Resource link|Jerky|size=gigantic}}
Specifying an icon size that is not recognized does not return an error. Instead, it defaults to the small icon:
Errors
The following are error messages generated by calling the template incorrectly.
{{Resource link}}
With no arguments: Lua error in Module:ResourceLink at line 64: You must specify a resource. Please see the template documentation for how to use the parameters.
{{Resource link|Potatoes}}
Naming a resource that doesn't exist in the game: Lua error in Module:ResourceLink at line 41: No resource found with name: Potatoes. Please see the template documentation for how to use the parameters.
{{Resource link|huge|Jerky}}
The same goes for swapping the order of the parameters so that the resource is not first: Lua error in Module:ResourceLink at line 41: No resource found with name: huge. Please see the template documentation for how to use the parameters.