Template:Recipe/doc: Difference between revisions
(separated the documentation page) |
m (amending example for product and ingredient combo; removing note at the top) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== 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 | 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 <code>product=</code> and <code>building=</code>, 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. | |||
{| class="wikitable" | {| class="wikitable" | ||
! | ! Parameter !! Type !!colspan=2| 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 <code>product</code>.) | ||
| <code>< | |rowspan=3| '''At least<br />one of these<br /> 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" ||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. | ||
| | |||
|} | |} | ||
== Examples == | |||
=== Basic usage === | |||
<pre>{{Recipe|Crystalized Dew|Brickyard}}</pre> | |||
Makes a table of exactly one recipe, for the specified product, in the specified building. | |||
{{Recipe|Crystalized Dew|Brickyard}} | |||
<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}} | |||
<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}} | |||
== Other examples == | |||
<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}} | |||
<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 both (a) gathered and (b) produced in industry buildings will the results be different. There is currently no way to match only recipes with empty ingredients except by making separate boxes for separate buildings. | |||
{{Recipe|product=Meat|ingredient=Plant Fiber}} | |||
{{Recipe|product=Meat}} | |||
<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}} | |||
However, specifying a product instead makes a list of buildings, those where that product is made: | |||
{{Recipe|product=Oil|display=list}} | |||
The following are generated by calling the template | <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}} | |||
<pre>{{Recipe|building=Small Warehouse}}</pre> | |||
<pre>{{Recipe|Flour|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}} | |||
{{Recipe|Flour|Brickyard}} | |||
=== 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}} | <pre>{{Recipe}}</pre> | ||
With no parameters: {{Recipe}} | |||
< | <pre>{{Recipe|product=Reeds}}</pre> | ||
<pre>{{Recipe|building=Alchemists' Hut}}</pre> | |||
Misspelling the name of a resource: {{Recipe|product=Reeds}} | |||
{{Recipe| | Or the name of a building: {{Recipe|building=Alchemists' Hut}} | ||
< | <pre>{{Recipe|Scribe}}</pre> | ||
Forgetting the second pipe when only specifying the building: {{Recipe|Scribe}} | |||
<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}} | |||
{{Recipe|| | <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}} |
Latest revision as of 21:27, 31 October 2024
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.
Building | Grade | Ingredient #1 | Ingredient #2 | Ingredient #3 | Product | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
★ 0:42 |
|
|
|
2 |
{{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.
Building | Grade | Ingredient | Product | |||
---|---|---|---|---|---|---|
|
★ 0:00 |
|
1 Leisure | |||
|
★ 0:00 |
|
1 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.
Building | Grade | Ingredient | Product | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
★★★ 1:03 |
|
5 Oil | |||||||||||
|
★ 1:24 |
|
10 Flour |
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.
- Oil (★★★)
- Oil (★★)
- Flour (★)
- Flour (★★)
- Flour (★★★)
- Leather (★)
- Meat (★)
- Ale (★)
- Ale (★★)
- Ale (★★★)
- Pack of Crops (☆)
- Pack of Crops (★)
- Pack of Crops (★★)
- Pack of Crops (★★★)
- Porridge (★★)
- Porridge (★★★)
- Eggs (★)
{{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 both (a) gathered and (b) produced in industry buildings will the results be different. There is currently no way to match only recipes with empty ingredients except by making separate boxes for separate buildings.
Building | Grade | Ingredient | Product | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
★ 1:24 |
|
10 |
Building | Grade | Ingredient | Product | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
★★ 0:17 |
— | 1 | |||||||||||
|
★ 0:25 |
— | 1 | |||||||||||
|
★ 1:24 |
|
10 |
{{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:
- Flawless Druid's Hut (★★★)
- Press (★★★)
- Druid's Hut (★★★)
- Butcher (★★)
{{Recipe||Supplier|Grain}}
Forgetting to explicitly name the ingredient parameter with ingredient=
does not result in an error, but the ingredient is ignored:
Building | Grade | Ingredient #1 | Ingredient #2 | Product | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
★★ 1:03 |
— |
|
10 Flour | |||||||||
|
★★ 0:42 |
— |
|
2 Planks | |||||||||
|
★★ 1:24 |
|
|
10 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.
No recipes. |
---|
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: Lua error in Module:RecipeController at line 160: You must specify a product, building, or ingredient. Please see the template documentation for how to use the parameters.
{{Recipe|product=Reeds}}
{{Recipe|building=Alchemists' Hut}}
Misspelling the name of a resource: Lua error in Module:RecipeController at line 160: You must specify a product, building, or ingredient. Please see the template documentation for how to use the parameters.
Or the name of a building: Lua error in Module:RecipeController at line 160: You must specify a product, building, or ingredient. Please see the template documentation for how to use the parameters.
{{Recipe|Scribe}}
Forgetting the second pipe when only specifying the building: Lua error in Module:RecipeController at line 160: You must specify a product, building, or ingredient. Please see the template documentation for how to use the parameters.
{{Recipe|||Grain}}
Using 3 pipes to skip product and building, but not explicitly naming the ingredient parameter with ingredient=
: Lua error in Module:RecipeController at line 160: You must specify a product, building, or ingredient. Please see the template documentation for how to use the parameters.
{{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): Lua error in Module:RecipeController at line 160: You must specify a product, building, or ingredient. Please see the template documentation for how to use the parameters.