Template:Recipe/doc: Difference between revisions

From Against the Storm Official Wiki
Created to move documentation to a subpage
Revised doc for this version
Line 1: Line 1:
{{c|{{ColorRed}}|Important template author note: Writing this doc revealed a few edge cases that are not being handled correctly--nothing major, just edge cases. I will fix these as soon as I can. In the meantime, the documentation is correct for how things ''will'' be, once the template is fixed.}}
== Overview ==
== Overview ==


Line 31: Line 33:
| display || "list" ||colspan=2| If you include <code>display=list</code> it overrides the table display into a bulleted list of products or buildings (depending on which you specified). Useful for populating larger tables or between paragraphs where displaying the entire recipe is excessive or irrelevant.
| display || "list" ||colspan=2| If you include <code>display=list</code> it overrides the table display into a bulleted list of products or buildings (depending on which you specified). Useful for populating larger tables or between paragraphs where displaying the entire recipe is excessive or irrelevant.
|}
|}
== Errors ==
When a product, service, building, or ingredient is not spelled correctly or is not a valid name, the template returns an error message to help you locate the spelling or name mistake.
'''Example:'''
Broken: <code><nowiki>{{Recipe|building=Alchemists' Hut}}</nowiki></code>
{{Recipe|building=Alchemists' Hut}}
Fixed: <code><nowiki>{{Recipe|building=Alchemist's Hut}}</nowiki></code>
{{Recipe|building=Alchemist's Hut}}
There may be cases where the name you should use to look up a good or building is not the right name. Please post these to this template's discussion page.


== Examples ==
== Examples ==


=== Basic Usage for Products and Buildings ===
=== Basic usage ===
 
A standard use of the template to show exactly one recipe for a product or service, in one building:


<pre>{{Recipe|Crystalized Dew|Brickyard}}</pre>
<pre>{{Recipe|Crystalized Dew|Brickyard}}</pre>
 
Makes a table of exactly one recipe, for the specified product, in the specified building.
Yields:
 
{{Recipe|Crystalized Dew|Brickyard}}
{{Recipe|Crystalized Dew|Brickyard}}


Alternatively, for a service building:


<pre>{{Recipe|Leisure|Tavern}}</pre>
<pre>{{Recipe||Tavern}}</pre>
Makes a table showing the services and service goods in the specified building. Note the double-pipe character (||), which skips specifying the product. If you prefer more readable template calls, you can write <code>building=</code> instead of two pipes.
{{Recipe||Tavern}}


Yields:


{{Recipe|Leisure|Tavern}}
<pre>{{Recipe|building=Press|ingredient=Grain}}</pre>
Makes a table of the recipes that use (instead of produce) the specified ingredient. If you omit the building, you will get a ''much'' longer table of all recipes that use Grain.
{{Recipe|building=Press|ingredient=Grain}}


Here are several ways to call the template for products and buildings.
{| class="wikitable mw-collapsible"
! Parameter(s) !! Example(s) !! Expected outcome
|-
| no parameters || <code><nowiki>{{Recipe}}</nowiki></code> || an error
|-
| product (or service) and building
|style="white-space: nowrap"| <code><nowiki>{{Recipe|Crystalized Dew|Brickyard}}</nowiki></code> <br> <code><nowiki>{{Recipe|product=Crystalized Dew|building=Brickyard}}</nowiki></code>
| A table with exactly one row.
|-
| product (or service) only
|style="white-space: nowrap"| <code><nowiki>{{Recipe|Pie}}</nowiki></code> <br> <code><nowiki>{{Recipe|product=Pie}}</nowiki></code>
| A table with several rows, one for each building in which '''Pie''' can be produced.
|-
| building only
|style="white-space: nowrap"| <code><nowiki>{{Recipe||Market}}</nowiki></code> ''(note the double pipe)'' <br> <code><nowiki>{{Recipe|building=Market}}</nowiki></code>
| A table with several rows, one for each service provided by the '''Market.'''
|-
| product (or service), but with output override
|style="white-space: nowrap| <code><nowiki>{{Recipe|Crystalized Dew|display=list}}</nowiki></code>
| A short list of buildings and their efficiency stars that easily fit within another table:<br />
{{Recipe|Crystalized Dew|display=list}}
|}


=== Ingredients ===
== Other examples ==


Unlike when specifying the product (or service) and/or building, when you specify the ingredient, you explicitly must name the parameter with <code>ingredient=</code> in the template. Currently, you cannot select both a product and an ingredient (for example, all recipes where Berries are the ingredient and Pie is the product), because this is redundant with the product parameter by itself (since there is currently only one arrangement of ingredients and options that will make a product).
<pre>{{Recipe|ingredient=Grain|display=list}}</pre>
To show all of those recipes, we can instead use the display override to show a bulleted list with much less information overall but in a much more compact form.
{{Recipe|ingredient=Grain|display=list}}


The results of specifying the ingredient without also filtering on a building can display a long table. But on a resource's page, this information is expected to be valuable.


<pre>{{Recipe|ingredient=Wine}}</pre>
<pre>{{Recipe|product=Meat|ingredient=Plant Fiber}}</pre>
<pre>{{Recipe|product=Meat}}</pre>
Specifying both the product and ingredient is redundant in most cases. Only when products can be gathered or produced in industry buildings will the results be different:
{{Recipe|product=Meat|ingredient=Plant Fiber}}


Yields:
{{Recipe|product=Meat}}


{{Recipe|ingredient=Wine}}


<pre>{{Recipe|building=Lumber Mill|ingredient=Wine}}</pre>


Yields:
<pre>{{Recipe|building=Press|display=list}}</pre>
<pre>{{Recipe|product=Oil|display=list}}</pre>
The bulleted list example above was made by specifying the Grain ingredient, which resulted in a list of products made from that ingredient. Specifying a building also makes a list of products, those made in that building:
{{Recipe|building=Press|display=list}}


{{Recipe|building=Lumber Mill|ingredient=Wine}}
However, specifying a product instead makes a list of buildings, those where that product is made:
{{Recipe|product=Oil|display=list}}




=== Further Examples and Errors ===
<pre>{{Recipe||Supplier|Grain}}</pre>
Forgetting to explicitly name the ingredient parameter with <code>ingredient=</code> does not result in an error, but the ingredient is ignored:
{{Recipe||Supplier|Grain}}


The following are generated by calling the template as shown in the parameter examples table above.


1. product and building:
<pre>{{Recipe|building=Small Warehouse}}</pre>
 
<pre>{{Recipe|Flour|Brickyard}}</pre>
<pre>{{Recipe|Crystalized Dew|Brickyard}}</pre>
Asking for buildings with no recipes does not result in an error, but an empty table. Empty tables can also happen if you ask for a combination of product, building, and ingredient which are valid but result in no recipes.
 
{{Recipe|building=Small Warehouse}}
Yields:
 
{{Recipe|Crystalized Dew|Brickyard}}


2. product only
{{Recipe|Flour|Brickyard}}


<pre>{{Recipe|Pie}}</pre>


Yields:
=== Errors ===


{{Recipe|Pie}}
The following are error messages generated by calling the template incorrectly.


3. building only
Note: If you are having trouble understanding how the template is understanding your parameters, the caption can help!
 
<pre>{{Recipe|building=Market}}</pre>
 
Yields:
 
{{Recipe|building=Market}}
 
4. with the output override
 
<pre>{{Recipe|Crystalized Dew|display=list}}</pre>
 
Yields:
 
{{Recipe|Crystalized Dew|display=list}}
 
5 with the output override but specifying a building
 
<pre>{{Recipe|building=Beanery|display=list}}</pre>
 
Yields:
 
{{Recipe|building=Beanery|display=list}}
 
The following are error states generated by calling the template incorrectly.
 
6. with no parameters


<pre>{{Recipe}}</pre>
<pre>{{Recipe}}</pre>
With no parameters: {{Recipe}}


Yields:


{{Recipe}}
<pre>{{Recipe|product=Reeds}}</pre>
<pre>{{Recipe|building=Alchemists' Hut}}</pre>
Misspelling the name of a resource: {{Recipe|product=Reeds}}


7. using only one pipe and not specifying that the provided name is the building
Or the name of a building: {{Recipe|building=Alchemists' Hut}}


<pre>{{Recipe|Scribe}}</pre>


Yields:
<pre>{{Recipe|Scribe}}</pre>
Forgetting the second pipe when only specifying the building: {{Recipe|Scribe}}


{{Recipe|Scribe}}


8. asking for products or buildings with no recipes
<pre>{{Recipe|||Grain}}</pre>
Using 3 pipes to skip product and building, but not explicitly naming the ingredient parameter with <code>ingredient=</code>: {{Recipe|||Grain}}


<pre>{{Recipe|building=Small Warehouse}}</pre>


Yields:
<pre>{{Recipe|product=Smoothies}}</pre>
 
Naming a product (or building, or ingredient) that doesn't exist in the game (or misspelling or mis-punctuating a building name): {{Recipe|product=Smoothies}}
{{Recipe|building=Small Warehouse}}

Revision as of 04:03, 31 October 2024

Important template author note: Writing this doc revealed a few edge cases that are not being handled correctly--nothing major, just edge cases. I will fix these as soon as I can. In the meantime, the documentation is correct for how things will be, once the template is fixed.

Overview

Creates a detailed table showing one or more recipes.

Use whenever you need to show a wiki-linked, user-friendly, sortable, and always-up-to-date version of the in-game recipe book instead of a screenshot. You can get very specific and narrow down the table to only one recipe with the parameters.

The table mimics the in-game recipe book with the building, efficiency grade and production time, ingredients, and product or service.

The table is completely data-driven, based on the parameters. It validates input, retrieves all necessary data, and handles all formatting.

The normal usage for this template produces a large table that typically fills the width of the article. (In rare cases, the table can overrun into the margin. This is a known issue and steps have already been taken to reduce the width of the table.)

Parameters

Product, Building, or Ingredient

At least one of these is required, and combinations are allowed. All names provided must be spelled (and, for buildings, punctuated) correctly to match the in-game name. These names will be the same as the articles for those goods and buildings.

If you do not wish to write the code product= and building=, you may skip that. If you skip naming them, they must appear in that order, and you cannot skip the product name. The ingredient must always be named. In the future, because building names and resource names are mutually exclusive, this template may be made more flexible with the product and building parameter.

Parameter Type Description
product string The name of the product or service associated with the recipe. (If you specify a service, do not change the parameter name from product.) At least
one of these
is required.
building string The name of the building where the recipe is produced.
ingredient string The name of any ingredient in a recipe.
display "list" If you include display=list it overrides the table display into a bulleted list of products or buildings (depending on which you specified). Useful for populating larger tables or between paragraphs where displaying the entire recipe is excessive or irrelevant.

Examples

Basic usage

{{Recipe|Crystalized Dew|Brickyard}}

Makes a table of exactly one recipe, for the specified product, in the specified building.

1 Recipe for Crystalized Dew in the Brickyard
Building Grade Ingredient #1 Ingredient #2 Ingredient #3 # Product
Brickyard ★
0:42
3 Herbs Herbs
3 Insects Insects
3 Resin Resin
3 Vegetables Vegetables
3 Algae Algae
4 Stone Stone
4 Clay Clay
3 Salt Salt
10 Storm Water Storm Water
14 Clearance Water Clearance Water
18 Drizzle Water Drizzle Water
2 Crystalized Dew


{{Recipe||Tavern}}

Makes a table showing the services and service goods in the specified building. Note the double-pipe character (||), which skips specifying the product. If you prefer more readable template calls, you can write building= instead of two pipes.

2 Recipes in the Tavern
Buildings Grade Ingredient # Product
Tavern ★
0:00
1 Ale Ale
1 Leisure Leisure
Tavern ★
0:00
1 Wine Wine
1 Luxury Luxury


{{Recipe|building=Press|ingredient=Grain}}

Makes a table of the recipes that use (instead of produce) the specified ingredient. If you omit the building, you will get a much longer table of all recipes that use Grain.

2 Recipes using Grain in the Press
Buildings Grade Ingredient # Product
Press ★
1:24
8 Grain Grain
8 Mushrooms Mushrooms
8 Roots Roots
8 Algae Algae
10 Flour Flour
Press ★★★
1:03
2 Grain Grain
2 Meat Meat
2 Vegetables Vegetables
2 Plant Fiber Plant Fiber
2 Fish Fish
5 Oil Oil


Other examples

{{Recipe|ingredient=Grain|display=list}}

To show all of those recipes, we can instead use the display override to show a bulleted list with much less information overall but in a much more compact form.



{{Recipe|product=Meat|ingredient=Plant Fiber}}
{{Recipe|product=Meat}}

Specifying both the product and ingredient is redundant in most cases. Only when products can be gathered or produced in industry buildings will the results be different:

1 Recipe for Meat using Plant Fiber
Building Grade Ingredient # Product
Ranch Ranch ★
1:24
8 Plant Fiber Plant Fiber
8 Reed Reed
8 Algae Algae
8 Grain Grain
5 Vegetables Vegetables
10 Meat


3 Recipes for Meat
Buildings Grade Ingredient # Product
Trappers' Camp Trappers' Camp ★★
0:17
— 1 Meat
Ranch Ranch ★
1:24
8 Plant Fiber Plant Fiber
8 Reed Reed
8 Algae Algae
8 Grain Grain
5 Vegetables Vegetables
10 Meat
Small Trappers' Camp Small Trappers' Camp ★
0:25
— 1 Meat



{{Recipe|building=Press|display=list}}
{{Recipe|product=Oil|display=list}}

The bulleted list example above was made by specifying the Grain ingredient, which resulted in a list of products made from that ingredient. Specifying a building also makes a list of products, those made in that building:


However, specifying a product instead makes a list of buildings, those where that product is made:



{{Recipe||Supplier|Grain}}

Forgetting to explicitly name the ingredient parameter with ingredient= does not result in an error, but the ingredient is ignored:

3 Recipes in the Supplier
Buildings Grade Ingredient #1 Ingredient #2 # Product
Supplier ★★
1:03
—
7 Grain Grain
7 Mushrooms Mushrooms
7 Roots Roots
7 Algae Algae
10 Flour Flour
Supplier ★★
0:42
—
5 Wood Wood
2 Planks Planks
Supplier ★★
1:24
5 Leather Leather
5 Scales Scales
3 Oil Oil
3 Meat Meat
3 Salt Salt
10 Waterskins Waterskins


{{Recipe|building=Small Warehouse}}
{{Recipe|Flour|Brickyard}}

Asking for buildings with no recipes does not result in an error, but an empty table. Empty tables can also happen if you ask for a combination of product, building, and ingredient which are valid but result in no recipes.

0 Recipes in the Small Warehouse
Building Grade Ingredient # Product
No recipes.


0 Recipes for Flour in the Brickyard
Building Grade Ingredient # Product
No recipes.


Errors

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

Note: If you are having trouble understanding how the template is understanding your parameters, the caption can help!

{{Recipe}}

With no parameters: [Recipe needs at least a product, building, or ingredient]


{{Recipe|product=Reeds}}
{{Recipe|building=Alchemists' Hut}}

Misspelling the name of a resource: [Recipe product not found: Reeds]


Or the name of a building: [Recipe building not found: Alchemists' Hut]


{{Recipe|Scribe}}

Forgetting the second pipe when only specifying the building: [Recipe product not found: Scribe]


{{Recipe|||Grain}}

Using 3 pipes to skip product and building, but not explicitly naming the ingredient parameter with ingredient=: [Recipe needs at least a product, building, or ingredient]


{{Recipe|product=Smoothies}}

Naming a product (or building, or ingredient) that doesn't exist in the game (or misspelling or mis-punctuating a building name): [Recipe product not found: Smoothies]