Template:Recipe: Difference between revisions

From Against the Storm Official Wiki
(added include only for template definition; improved some descriptions; added named argument version to the template)
m (editing description)
Line 2: Line 2:
</includeonly><noinclude>
</includeonly><noinclude>


== Template definition ==
<code><nowiki>{{#invoke:RenderRecipe|renderRecipe|product={{{1|{{{product|}}} }}}|building={{{2|{{{building|}}} }}} }}</nowiki></code>
<code><nowiki>{{#invoke:RenderRecipe|renderRecipe|product={{{1|{{{product|}}} }}}|building={{{2|{{{building|}}} }}} }}</nowiki></code>
and used like this:
<code><nowiki>{{Recipe|product|building}}</nowiki></code>





Revision as of 00:14, 13 February 2023


{{#invoke:RenderRecipe|renderRecipe|product={{{1|{{{product|}}} }}}|building={{{2|{{{building|}}} }}} }}

and 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.

{{Recipe}} yields:

RenderRecipe error: Invalid template parameters. This template requires at least a product or building.


{{Recipe|Crystalized Dew|Brickyard}} yields:

Lua error in Module:RenderRecipe at line 106: attempt to call field 'getRecipeAtBuilding' (a nil value).


{{Recipe|Pie}} yields:

Lua error in Module:RenderRecipe at line 120: attempt to call field 'getRecipeForProduct' (a nil value).


{{Recipe||Scribe}} yields:

Lua error in Module:RenderRecipe at line 142: attempt to call field 'getBuildingsRecipes' (a nil value).