Template:Building link: Difference between revisions

From Against the Storm Official Wiki
m (improved categories)
m (Unblocking now that the module is updated. sorry about that!)
Tag: Manual revert
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#invoke:BuildingLink|renderLink|building={{{1|{{{building|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</includeonly><noinclude>
<includeonly>{{#invoke:BuildingLink|main
|name={{{name|{{{1|}}}}}}
|size={{{size|}}}
|display={{{display|}}} <!-- the rest of the unnamed parameters are handled in the module -->
}}</includeonly><noinclude>


== Overview ==
{{Documentation}}
 
This template makes icons and short wiki links to a building's page. This template standardizes the display of icons and buildings throughout the wiki and simplifies the amount of writing needed.
 
A shortcut template also exists, <code><nowiki>{{bl}}</nowiki></code>, and its use is encouraged to make writing links even easier.
 
== Usage ==
 
This template is used like this: <code><nowiki>{{Building link|building|iconsize}}</nowiki></code>. Use the name of the building as it appears in the game.
 
Since the rendering of the template ends in a standard wikilink, you can append an ''s'' after the template to write the plural of the building. Just like a regular wiki link, <code><nowiki>{{bl|Kiln}}s</nowiki></code> yields {{bl|Kiln}}s, plural, with the ''s'' included in the link text.
 
Giving the template a building name will result in a short link to the wiki page for that building. This is useful in-line with text in paragraphs, where an icon would be too small to recognize but anything large enough to recognize would disrupt the display of the lines of text when it tries to wrap around the icon.
 
Telling the template what size to make the icon will add an icon before the name of the building that also links to the wiki page. This is useful when creating tables where the building icon aids recognition and where there is space to do so, for example in a table. If the building is not known to the data modules behind the scenes, an error will appear.
 
The default is no icon, for use in-line with text. You can also use <code>med</code>, <code>large</code>, or <code>huge</code> 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"
! Parameter !! Examples !! Expected outcome
|-
| None
|style="white-space: nowrap"| <code><nowiki>{{Building link}}</nowiki></code>
| An error.
|-
| Building name
|style="white-space: nowrap"| <code><nowiki>{{Building link|Monastery}}</code></nowiki>
| A link to the wiki page for the building.
|-
| Building name and a "medium" icon size
|style="white-space: nowrap"| <code><nowiki>{{bl|Small Farm|med}}</code></nowiki>
| A moderately sized icon and a link to its wiki page.
|-
| Building name and a "large" icon size
|style="white-space: nowrap"| <code><nowiki>{{bl|Foragers' Camp|large}}</code></nowiki>
| A large building icon and a link to its wiki page.
|-
| Building name and a "huge" icon size
|style="white-space: nowrap"| <code><nowiki>{{bl|Cookhouse|huge}}</code></nowiki>
| A very large building 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>{{Building link|Monastery}}</nowiki></code> yields:
 
{{Building_link|Monastery}}
 
2. <code><nowiki>{{bl|Small Farm|med}}</nowiki></code> yields:
 
{{bl|Small Farm|med}}
 
3. <code><nowiki>{{bl|Foragers' Camp|large}}</nowiki></code> yields:
 
{{bl|Foragers' Camp|large}}
 
4. <code><nowiki>{{bl|Cookhouse|huge}}</nowiki></code> yields:
 
{{bl|Cookhouse|huge}}
 
The following are error messages generated by calling the template incorrectly.
 
5. With no arguments, <code><nowiki>{{Building_link}}</nowiki></code> yields:
 
'''{{Building_link}}'''
 
6. With the name of something that doesn't exist in the game, <code><nowiki>{{Building_link|Cookhuse}}</nowiki></code> yields:
 
'''{{Building_link|Cookhuse}}'''
 
7. With no building but an icon size, <code><nowiki>{{Building_link||large}}</nowiki></code> yields:
 
'''{{Building_link||large}}'''
 
Finally, providing an icon size that is not recognized does not break the template.
 
8. With a valid building but invalid icon size, <code><nowiki>{{Building link|Cookhouse|gigantic}}</nowiki></code> yields:
 
{{Building_link|Cookhouse|gigantic}}


[[Category:Link templates]]
[[Category:Link templates]]
[[Category:Lua-based templates]]</noinclude>
[[Category:Lua-based templates]]</noinclude>

Latest revision as of 01:44, 30 October 2024


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

Overview

Creates a link to a building's page.

The template validates that you have correctly spelled the building name and can include an icon. Any links returned by this template should have articles and not be redlinks.

A shortcut template exists for this template, Template:bl. You can use {{bl}} instead of {{Building link}} with the same parameters.

Parameters

Building

The name of the building is the only required parameter. Use the name as it appears in-game, including apostrophes (for example, the Woodcutters' Camp—not Woodcutter's Camp). A missing or mispelled (or mis-punctuated) building 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 building before any other parameters.

Parameter Type Description
name string Required. The name of the building, 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 buildings is none, 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.
unnamed parameter string Including this formats the link with the plural name of the building. You may use either s or es to append it to the end of the link in a highly readable way, like this: {{bl|Cookhouse|s}}.

Building links that are written into paragraphs should use no icon, which is the default. The small icon for buildings is not recognizable (compared to species, resources, or specializations). Avoid it unless necessary, but it is available in case it is needed.

Note that adding "s" after the template call no longer includes the "s" in the link as it used to.

Examples

Basic usage

{{Building link|Trappers' Camp}}

Makes a simple text-only link to the Trappers' Camp article for use in-line in paragraphs like this that discuss villagers trapping and gathering things. Remember that using the small version of building icons like the Trappers' Camp Trappers' Camp is strongly advised against, because there aren't enough pixels to make them recognizable to the broad audience of this wiki.


{{Building link|Trappers' Camp|size=medium}}

Yields an icon just big enough to be recognizable. Suitable for tables that list the buildings where layout provides some space for icons:

Trappers' Camp Trappers' Camp


{{Building link|name=Ranch|large}}

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

Ranch Ranch


{{Building link|Ranch|size=huge}}

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

Ranch Ranch

Other examples

{{Building link|Ranch|s}}

Formats the link so the name appears plural, but still links to the correct page (hover to see tooltip, or click):

Ranches


{{Building link|Apothecary|s|size=none}}

Mentioning how important Apothecaries are to your villagers does format the building name correctly as plural. The pages for the names of buildings ending in -y when plural like the Breweries have already been created as redirect pages, so you may use them freely:


{{Building link|Trappers' Camp|s|size=gigantic}}

Specifying an icon size that is not recognized does not return an error. Instead, it defaults to no icon:

Trappers' Camps

Errors

The following are error messages generated by calling the template incorrectly.

{{Building link}}

With no arguments: Lua error in Module:BuildingLink at line 88: You must specify a building. Please see the template documentation for how to use the parameters.


{{Building link|Library}}

Naming a building that doesn't exist in the game: Lua error in Module:BuildingLink at line 59: No building found with name: Library. Please see the template documentation for how to use the parameters.


{{Building link|huge|Ranch|es}}

The same goes for swapping the order of the parameters so that the building is not first: Lua error in Module:BuildingLink at line 59: No building found with name: huge. Please see the template documentation for how to use the parameters.