Template:Resource link: Difference between revisions

From Against the Storm Official Wiki
(improved the template documentation; renamed product to resource for consistency)
(forgot to capture the display override parameter in the first place! Also moving doc to subpage)
Tag: Replaced
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#invoke:ResourceLink|renderLink|resource={{{1|{{{resource|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</includeonly><noinclude>
<includeonly>{{#invoke:ResourceLink|main
|name={{{name|{{{1|}}}}}}
|size={{{size|{{{2|{{{1|}}}}}}}}}
|display={{{display|}}}
}}</includeonly><noinclude>


<code><nowiki>{{#invoke:ResourceLink|renderLink|resource={{{1|{{{resource|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</nowiki></code>
{{Documentation}}


 
[[Category:Lua-based templates]]
This template is used like this: <code><nowiki>{{Resource link|resource|iconsize}}</nowiki></code>
[[Category:Link templates]]</noinclude>
 
 
This template calls <code>renderLink</code> in '''Module:ResourceLink''' to make icons and short wiki links to a resource's page. The icon can be small, huge, or in between. The small icon is sized appropriately to fit well into in-line text.
 
This template standardizes the display of icons and resourcesthroughout the wiki and simplifies the amount of writing that is necessary when adding new content pages.
 
 
A shortcut template also exists <code><nowiki>{{rl}}</nowiki></code>, to make writing a page with many resource links a little easier.
 
 
== Usage ==
 
Use the name of the resource name as it appears in the game. (The background code performs some normalization, but only to catch small mistakes in spacing or apostrophes.)
 
Giving the template a resource name will result in a text-sized icon and a link to the wiki page for that resource. This is useful in-line with text in paragraphs, where resource icons can still be recognized.
 
 
Telling the template what size to make the icon allows the icon to be larger and more distinguishable. This is useful when creating tables where a larger resource icon increases recognition. IF the resource is not known to the data modules behind the scenes, an error will appear.
 
The default is a small icon, for use in-line with text. You can also use <code>med</code>, <code>large</code>, <code>huge</code>, or write <code>small</code> explicitly, to describe the desired size of the icon, as you can see below.
 
 
Here are ways to call the template and the expected result:
 
{| class="wikitable"
! Argument !! Examples !! Expected outcome
|-
| None
|style="white-space: nowrap"| <code><nowiki>{{Resource link}}</nowiki></code>
| An error.
|-
| Resource name or <br /> Resource name and a "small" icon size
|style="white-space: nowrap"| <code><nowiki>{{Resource link|Biscuits}}</nowiki></code> <br /> <code><nowiki>{{Resource link|Crystalized Dew|small}}</nowiki></code>
| A small, text-sized icon and link to the wiki page for the resource.
|-
| Resource name and a "med" icon size
|style="white-space: nowrap"| <code><nowiki>{{Resource link|Biscuits|med}}</nowiki></code> <br /> <code><nowiki>{{Resource link|Training Gear|med}}</nowiki></code>
| A fair-sized resource icon and a link to its wiki page.
|-
| Resource name and a "large" icon size
|style="white-space: nowrap"| <code><nowiki>{{Resource link|Biscuits|large}}</nowiki></code> <br /> <code><nowiki>{{Resource link|Waterskins|large}}</nowiki></code>
| A large resource icon and a link to its wiki page.
|-
| Resource name and a "huge" icon size
|style="white-space: nowrap"| <code><nowiki>{{Resource link|Biscuits|huge}}</nowiki></code> <br /> <code><nowiki>{{Resource link|Pack of Trade Goods|huge}}</nowiki></code>
| A very large resource icon and a link to its wiki page.
|}
 
 
== Examples ==
 
The following are generated by calling the template, as shown in the examples in the table above.
 
 
1. <code><nowiki>{{Resource link|Biscuits}}</nowiki></code> yields:
 
{{Resource link|Biscuits}}
 
 
2. <code><nowiki>{{Resource link|Biscuits|med}}</nowiki></code> yields:
 
{{Resource link|Biscuits|med}}
 
 
3. <code><nowiki>{{Resource link|Biscuits|large}}</nowiki></code> yields:
 
{{Resource link|Biscuits|large}}
 
 
4. <code><nowiki>{{Resource link|Biscuits|huge}}</nowiki></code> yields:
 
{{Resource link|Biscuits|huge}}
 
 
The following are error messages generated by calling the template incorrectly.
 
 
5. With no arguments, <code><nowiki>{{Resource link}}</nowiki></code> yields:
 
'''{{Resource link}}'''
 
 
6. With the name of something that doesn't exist in the game, <code><nowiki>{{Resource link|Biscits}}</nowiki></code> yields:
 
'''{{Resource link|Biscits}}'''
 
 
7. With no resource but an icon size, <code><nowiki>{{Resource link||large}}</nowiki></code> yields:
 
'''{{Resource link||large}}'''
 
 
Finally, providing an icon size that is not recognized does not break the template.
 
 
8. With a valid resource but invalid icon size, <code><nowiki>{{Resource link|Biscuits|gigantic}}</nowiki></code> yields:
 
{{Resource link|Biscuits|gigantic}}</noinclude>

Latest revision as of 02:21, 10 November 2024


This is the Template Documentation from Template:Resource link/doc.

Overview

Creates a link to the article for a resource (or good).

Template:rl is a shortcut to this template. You can use {{rl}} instead of {{Resource 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:
  • none
  • small
  • medium
  • large
  • huge

The default for resources is small, suitable for paragraphs.

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 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:

Biscuits Biscuits


{{Resource link|name=Biscuits|large}}

Yields a large icon for good recognition for use in tables with space that allows it:

Biscuits Biscuits


{{Resource link|Biscuits|size=huge}}

Yields the largest icon, which is great for headlining tables featuring this resource:

Biscuits Biscuits


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|Biscuits|size=large|display=notext}}

Yields an icon with no label. This is useful in tables where the meanings are obvious or provided another way.

Biscuits


{{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:

Jerky Jerky


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.