Template:Recipe
{{#invoke:RenderRecipe|renderRecipe|product={{{1|{{{product|}}} }}}|building={{{2|{{{building|}}} }}} }}
This template is used like this:
{{Recipe|product|building}}
This template calls renderRecipe
in Module:RenderRecipe to get recipes for a product and/or a building. This will generate a new wikitable full of content from the game: buildings, stars of efficiency, ingredients, and products.
This template standardizes the display of recipes throughout this wiki and greatly simplifies the amount of writing that is necessary when adding new content pages, especially for resources and buildings.
Usage
Giving the template both a product and a building will result in a table with exactly one recipe. Giving the template either a product or a building will result in a table with (usually) more than one row. If nothing is provided, an error will appear identifying the expectation.
Here are ways to call the template, as they would be written in the article calling the template:
Argument | Examples | Expected outcome |
---|---|---|
None | {{Recipe}}
|
An error |
Product and building | {{Recipe|Crystalized Dew|Brickyard}} {{Recipe|product=Crystalized Dew|building=Brickyard}}
|
A table with one row. |
Product only | {{Recipe|Pie}} {{Recipe|product=Pie}}
|
A table with several rows, one for each building in which Pie can be produced. |
Building only | {{Recipe||Scribe}} (note the double pipe) {{Recipe|building=Scribe}}
|
A table with several rows, one for each product that can be produced in the Scribe. |
Examples
The following are generated by calling the template, as shown in the examples in the table above.
1. {{Recipe|Crystalized Dew|Brickyard}}
yields:
Lua error in Module:RenderRecipe at line 106: attempt to call field 'getRecipeAtBuilding' (a nil value).
2. {{Recipe|Pie}}
yields:
Lua error in Module:RenderRecipe at line 120: attempt to call field 'getRecipeForProduct' (a nil value).
3. {{Recipe||Scribe}}
yields:
Lua error in Module:RenderRecipe at line 142: attempt to call field 'getBuildingsRecipes' (a nil value).
The following are error states generated by calling the template incorrectly.
4. With no arguments, {{Recipe}}
yields:
RenderRecipe error: Invalid template parameters. This template requires at least a product or building.
5. Skipping the double pipe AND not specifying that the provided name is the building in {{Recipe|Scribe}}
yields:
Lua error in Module:RenderRecipe at line 120: attempt to call field 'getRecipeForProduct' (a nil value).
6. Mixing naming the arguments and not naming the arguments {{Recipe|product=Eggs|Ranch}}
yields:
Lua error in Module:RenderRecipe at line 120: attempt to call field 'getRecipeForProduct' (a nil value).
7. Specifying products or buildings with no recipes {{Recipe|Market}}
yields:
Lua error in Module:RenderRecipe at line 142: attempt to call field 'getBuildingsRecipes' (a nil value).