Template:Buildingbox/doc: Difference between revisions

From Against the Storm Official Wiki
(moving documentation to subpage)
 
m (Revised doc for this version)
Line 1: Line 1:
{{Buildingbox|name=Mine}}
== Overview ==


'''Buildingbox''' is a template that creates an infobox on the page by displaying data provided by template parameters and loading data about the building corresponding to the name requested. The infobox to the right on this page is an example.
Displays an infobox about a building on the right side of the page.


== Overview ==
The infobox is populated automatically based on the parameters, validates the input, retrieves all necessary data, and handles all related lookups and formatting.


This template should be used for all production, service, gathering, farming, and collecting buildings on the wiki—that is, any building with a recipe (not Hearths, Warehouses, or Housing). The template requires only the <code>name</code> parameter, which tells the code behind the scenes which building you want an infobox for.
This template can and should be used exactly once at the top of every article on buildings with workplaces (that is, not houses or decorations).


In the future, this template could be augmented to automatically create page categories based on the information retrieved. For example, the infobox for the [[Cookhouse]] could add categories for food production, complex food, crafting materials, large buildings, or even 2-star buildings.
In the future, this template could be augmented to automatically create page categories based on the information retrieved. For example, the infobox for the [[Cookhouse]] could add categories for food production, complex food, crafting materials, large buildings, or even 2-star buildings.
Line 11: Line 11:
== Parameters ==
== Parameters ==


Only the first, <code>name</code> is required, and it must be spelled correctly to match the in-game name of the building. Other parameters are optional, but add to the value of displaying the infobox.
=== Building ===
 
The name of the building is the only parameter, and it is required. It must be spelled correctly and match the in-game spelling and punctuation of the building. A reliable way of calling this template with the correct spelling on articles about a building is to use the mediawiki magic word <code><nowiki>{{PAGENAME}}</nowiki></code>, since all buildings' pages were carefully named to match the game data from which these template lookup and pull information.
 
If you do not wish to write the code <code>name=</code>, you may skip that. If any parameters are added later, you must specify the name of the building before any other parameters.


{|class="wikitable"
{|class="wikitable"
Line 17: Line 21:
! Parameter !! Type !! Description
! Parameter !! Type !! Description
|-
|-
| name || string || '''Required.''' The in-game name of the building for which you want to display the infobox. Will also serve as the header of the box.
| name || string || '''Required.''' The name of the building, as it appears in the game.
|-
| purpose || string || The overall purpose of the building, such as "Services" or omit this parameter. For example, if the purpose is "Industry," the infobox will already show "Industry" for the building's '''Category,''' so you may omit it.
|-
| species_preference || string || For buildings that provide services consumed by villagers, you may write which species prefers these services. For example, Leisure is preferred by "Beaver, Human." (Do not duplicate specialization information as species preferences.)
|-
| specializations || string || For buildings with specializations, you can include them here.
|}
|}


== Errors ==


When the template is called without a name, the template reminds you that it is required.
At this time, there are no other parameters for this template.


'''Example:'''
Note: An older version of this template had other parameters. This version is backwards compatible, and any additional parameters are automatically ignored.
 
== Examples ==
 
<!-- Adding this above where the example is written in the pre block for better alignment. -->
{{Buildingbox|Ancient Hearth}}
=== Basic usage ===
 
<pre>{{Buildingbox|Ancient Hearth}}</pre>
Creates the infobox seen on the right side of this article.
 
{{Clear}}
=== Errors ===
 
The following are error message generated by calling the template incorrectly.


<pre>{{Buildingbox}}</pre>
<pre>{{Buildingbox}}</pre>


Yields:
With no arguments: {{Buildingbox}}
 
{{Buildingbox}}


When providing the name of a building, it is important that it is spelled correctly, including any punctuation. Otherwise, an error will return from the data module.


'''Example:'''
<pre>{{Buildingbox|name=Alchemist Hut}}</pre>
With a misspelled building name: {{Buildingbox|name=Alchemist Hut}}


Broken: <code><nowiki>{{Buildingbox|name=Alchemist Hut}}</nowiki></code>


{{Buildingbox|name=Alchemist Hut}}
<pre>{{Buildingbox|name=Library}}</pre>
Naming a building that doesn't exist in the game: {{Buildingbox|name=Library}}


Fixed:  <code><nowiki>{{Buildingbox|name=Alchemist's Hut}}</nowiki></code>


{{Buildingbox|name=Alchemist's Hut}}
<pre>{{Buildingbox|Another parameter first|Ancient Hearth}}</pre>
The same goes for swapping the order of parameters so that the building is not first: {{Buildingbox|Another parameter first|Ancient Hearth}}

Revision as of 02:20, 31 October 2024

Overview

Displays an infobox about a building on the right side of the page.

The infobox is populated automatically based on the parameters, validates the input, retrieves all necessary data, and handles all related lookups and formatting.

This template can and should be used exactly once at the top of every article on buildings with workplaces (that is, not houses or decorations).

In the future, this template could be augmented to automatically create page categories based on the information retrieved. For example, the infobox for the Cookhouse could add categories for food production, complex food, crafting materials, large buildings, or even 2-star buildings.

Parameters

Building

The name of the building is the only parameter, and it is required. It must be spelled correctly and match the in-game spelling and punctuation of the building. A reliable way of calling this template with the correct spelling on articles about a building is to use the mediawiki magic word {{PAGENAME}}, since all buildings' pages were carefully named to match the game data from which these template lookup and pull information.

If you do not wish to write the code name=, you may skip that. If any parameters are added later, 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.


At this time, there are no other parameters for this template.

Note: An older version of this template had other parameters. This version is backwards compatible, and any additional parameters are automatically ignored.

Examples

Ancient Hearth

Hearth
(City Buildings)

The heart of the colony is protected by the Holy Flame. Villagers gather here to rest, eat, and receive clothing. If the fire goes out, people will lose hope.

Specialization bonus:
Warmth (Comfort) Warmth (Comfort) Lizards

Small Hearth icon.png

1 Worker round.png Workers

Construction

None

0City score
0Build time
4 × 4Building size

Not movable

ID = `Small Hearth`

Basic usage

{{Buildingbox|Ancient Hearth}}

Creates the infobox seen on the right side of this article.

Errors

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

{{Buildingbox}}

With no arguments: Lua error in Module:Buildingbox at line 211: No building found with name: . Please see the template documentation for how to use the parameters.


{{Buildingbox|name=Alchemist Hut}}

With a misspelled building name: Lua error in Module:Buildingbox at line 211: No building found with name: Alchemist Hut. Please see the template documentation for how to use the parameters.


{{Buildingbox|name=Library}}

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


{{Buildingbox|Another parameter first|Ancient Hearth}}

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