Template:Recipe: Difference between revisions

From Against the Storm Official Wiki
(Connecting to the new template modules that are easier to maintain)
(Revised the documentation, now includes how to use the ingredient parameter)
Line 6: Line 6:
</includeonly><noinclude>
</includeonly><noinclude>


Generates recipe tables. Use this wherever you need to show how to use [[Resources|Goods]] or [[Buildings]].


<code><nowiki>{{#invoke: Recipe|render
== Overview ==
| product= {{{ 1|{{{product|}}} }}}
Create a concise, sortable table using game data to show in-game recipes. The table mimics the layout of the in-game recipe browser, with the building, efficiency of the recipe, number of ingredients, and the product.
| building={{{ 2|{{{building|}}} }}}
| ingredient={{{ingredient|}}}
}}</nowiki></code>


== Parameters ==


This template is used like this:
At least one of these is required. Depending on which parameters you provide, the table may ignore other parameters. If the names provided are not spelled correctly (including punctuation), matching their in-game names, the recipe will return an error.
<code><nowiki>{{Recipe|product|building|ingredient}}</nowiki></code>


{| class="wikitable"
! Parameter !! Type !! Description
|-
| product || string || The name of the product associated with the recipe. Can be used in conjunction with <code>building</code> to display exactly one recipe.
|-
| building || string || The name of the building where the recipe is produced. Can be used in conjunction with <code>product</code> to display exactly one recipe.
|-
| ingredient || string || The name of an ingredient in a recipe. If you provide this parameter, the template does '''not''' filter the results further, but ignores the other parameters and returns a long table of all recipes where the ingredient could be used.
|}


This template calls <code>renderRecipe</code> 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.
== Errors ==


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.
When a product, 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:'''


== Usage ==
Broken: <code><nowiki>{{Recipe|building=BrickOven}}</nowiki></code>


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.
{{Recipe|building=BrickOven}}


Here are ways to call the template, as they would be written in the article calling the template:
Fixed: <code><nowiki>{{Recipe|building=Brick Oven}}</nowiki></code>


{| class="wikitable"
{{Recipe|building=Brick Oven}}
 
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 ==
 
=== Basic Usage for Products and Buildings ===
 
A standard use of the template to show exactly one recipe for a product, in one building:
 
<pre>{{Recipe|Crystalized Dew|Brickyard}}</pre>
 
Yields:
 
{{Recipe|Crystalized Dew|Brickyard}}
 
Here are several ways to call the template for products and buildings.
 
{| class="wikitable mw-collapsible"
! Argument !! Examples !! Expected outcome
! Argument !! Examples !! Expected outcome
|-
|-
| None
| no parameters || <code><nowiki>{{Recipe}}</nowiki></code> || an error
| <code><nowiki>{{Recipe}}</nowiki></code>
| An error
|-
|-
| Product and building
| product 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>
|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 one row.
| A table with exactly one row.
|-
|-
| Product only
| product only
| style="white-space: nowrap" | <code><nowiki>{{Recipe|Pie}}</nowiki></code> <br> <code><nowiki>{{Recipe|product=Pie}}</nowiki></code>
|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.
| A table with several rows, one for each building in which '''Pie''' can be produced.
|-
|-
| Building only
| building only
| style="white-space: nowrap" | <code><nowiki>{{Recipe||Scribe}}</nowiki></code> ''(note the double pipe)'' <br> <code><nowiki>{{Recipe|building=Scribe}}</nowiki></code>
|style="white-space: nowrap"| <code><nowiki>{{Recipe||Scribe}}</nowiki></code> ''(note the double pipe)'' <br> <code><nowiki>{{Recipe|building=Scribe}}</nowiki></code>
| A table with several rows, one for each product that can be produced in the '''Scribe.'''
| A table with several rows, one for each product that can be produced in the '''Scribe.'''
|}
|}


=== Ingredients ===
Unlike when specifying the product and/or building, when you specify the <code>ingredient</code>, you explicitly must name the parameter (with <code>ingredient=</code>...). When you do so, the template ignores the other parameters you may have provided. This can be confusing if, for example, you are looking for all of the recipes in the Brick Oven that use Herbs—this is not possible at this time. This may be fixed in the future if there are sufficient needs for further filtering.
The results of specifying the ingredient can be a long table. But on a resource's page, this information is expected to be valuable.
<pre>{{Recipe|ingredient=Wine}}</pre>
<pre>{{Recipe|building=Lumber Mill|ingredient=Wine}}</pre>
Both result in:
{{Recipe|ingredient=Wine}}
=== Further Examples and Errors ===


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


The following are generated by calling the template, as shown in the examples in the table above.
1. product and building:


<pre>{{Recipe|Crystalized Dew|Brickyard}}</pre>


1. <code><nowiki>{{Recipe|Crystalized Dew|Brickyard}}</nowiki></code> yields:
Yields:


{{Recipe|Crystalized Dew|Brickyard}}
{{Recipe|Crystalized Dew|Brickyard}}


2. product only
<pre>{{Recipe|Pie}}</pre>


2. <code><nowiki>{{Recipe|Pie}}</nowiki></code> yields:
Yields:


{{Recipe|Pie}}
{{Recipe|Pie}}


3. building only


3. <code><nowiki>{{Recipe||Scribe}}</nowiki></code> yields:
<pre>{{Recipe|building=Scribe}}</pre>


{{Recipe||Scribe}}
Yields:


{{Recipe|building=Scribe}}


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


4. with no parameters


4. With no arguments, <code><nowiki>{{Recipe}}</nowiki></code> yields:
<pre>{{Recipe}}</pre>


'''{{Recipe}}'''
Yields:


{{Recipe}}


5. Skipping the double pipe AND not specifying that the provided name is the building in <code><nowiki>{{Recipe|Scribe}}</nowiki></code> yields:
5. using only one pipe and not specifying that the provided name is the building


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


Yields:


6. Mixing naming the arguments and not naming the arguments <code><nowiki>{{Recipe|product=Eggs|Ranch}}</nowiki></code> yields:
{{Recipe|Scribe}}


'''{{Recipe|product=Eggs|Ranch}}'''
6. asking for products or buildings with no recipes


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


7. Specifying products or buildings with no recipes <code><nowiki>{{Recipe|Market}}</nowiki></code> yields:
Yields:


'''{{Recipe|building=Market}}'''</noinclude>
{{Recipe|building=Market}}
</noinclude>

Revision as of 03:37, 6 November 2023


Generates recipe tables. Use this wherever you need to show how to use Goods or Buildings.

Overview

Create a concise, sortable table using game data to show in-game recipes. The table mimics the layout of the in-game recipe browser, with the building, efficiency of the recipe, number of ingredients, and the product.

Parameters

At least one of these is required. Depending on which parameters you provide, the table may ignore other parameters. If the names provided are not spelled correctly (including punctuation), matching their in-game names, the recipe will return an error.

Parameter Type Description
product string The name of the product associated with the recipe. Can be used in conjunction with building to display exactly one recipe.
building string The name of the building where the recipe is produced. Can be used in conjunction with product to display exactly one recipe.
ingredient string The name of an ingredient in a recipe. If you provide this parameter, the template does not filter the results further, but ignores the other parameters and returns a long table of all recipes where the ingredient could be used.

Errors

When a product, 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: {{Recipe|building=BrickOven}}

Lua error in Module:RecipeData at line 274: No building found. Please check spelling and any punctuation like an apostrophe: BrickOven.


Fixed: {{Recipe|building=Brick Oven}}

Recipes in the Brick Oven.
BuildingIngredient #1 optionsIngredient #2 optionsIngredient #3 optionsProduct
Brick OvenBrick Oven

02:06
15Wood Wood
3 Coal Coal
Brick OvenBrick Oven
★★★
01:45
6Flour Flour
3Herbs Herbs
3Meat Meat
3Insects Insects
3Eggs Eggs
3Berries Berries
10 Pie Pie
Brick OvenBrick Oven

02:06
6Herbs Herbs
6Roots Roots
6Insects Insects
8Resin Resin
6Wood Wood
3Oil Oil
2Coal Coal
2Sea Marrow Sea Marrow
10 Incense Incense


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

Basic Usage for Products and Buildings

A standard use of the template to show exactly one recipe for a product, in one building:

{{Recipe|Crystalized Dew|Brickyard}}

Yields:

Recipe for Crystalized Dew in the Brickyard.
BuildingIngredient #1 optionsIngredient #2 optionsIngredient #3 optionsProduct
BrickyardBrickyard

00:42
3Herbs Herbs
3Insects Insects
3Resin Resin
3Vegetables Vegetables
4Stone Stone
4Clay Clay
10Storm Water Storm Water
14Clearance Water Clearance Water
18Drizzle Water Drizzle Water
2 Crystalized Dew Crystalized Dew


Here are several ways to call the template for products and buildings.

Argument Examples Expected outcome
no parameters {{Recipe}} an error
product and building {{Recipe|Crystalized Dew|Brickyard}}
{{Recipe|product=Crystalized Dew|building=Brickyard}}
A table with exactly 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.

Ingredients

Unlike when specifying the product and/or building, when you specify the ingredient, you explicitly must name the parameter (with ingredient=...). When you do so, the template ignores the other parameters you may have provided. This can be confusing if, for example, you are looking for all of the recipes in the Brick Oven that use Herbs—this is not possible at this time. This may be fixed in the future if there are sufficient needs for further filtering.

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

{{Recipe|ingredient=Wine}}
{{Recipe|building=Lumber Mill|ingredient=Wine}}

Both result in:

Recipes that require Wine.
BuildingIngredient #1 optionsIngredient #2 optionsIngredient #3 optionsProduct
ArtisanArtisan
★★
00:42
4Wine Wine
4Training Gear Training Gear
4Incense Incense
4Scrolls Scrolls
4Ale Ale
4Tea Tea
2 Pack of Luxury Goods Pack of Luxury Goods
CarpenterCarpenter
★★
00:42
4Wine Wine
4Training Gear Training Gear
4Incense Incense
4Scrolls Scrolls
4Ale Ale
4Tea Tea
2 Pack of Luxury Goods Pack of Luxury Goods
PressPress

00:42
5Wine Wine
5Training Gear Training Gear
5Incense Incense
5Scrolls Scrolls
5Ale Ale
5Tea Tea
2 Pack of Luxury Goods Pack of Luxury Goods
ScribeScribe
★★★
01:03
2Leather Leather
2Plant Fiber Plant Fiber
6Wood Wood
1Pigment Pigment
1Wine Wine
8 Scrolls Scrolls
Flawless Rain MillFlawless Rain Mill
★★★
01:03
2Leather Leather
2Plant Fiber Plant Fiber
6Wood Wood
1Pigment Pigment
1Wine Wine
8 Scrolls Scrolls
ClothierClothier

01:24
4Leather Leather
4Plant Fiber Plant Fiber
10Wood Wood
3Pigment Pigment
3Wine Wine
8 Scrolls Scrolls
Lumber MillLumber Mill

01:24
4Leather Leather
4Plant Fiber Plant Fiber
10Wood Wood
3Pigment Pigment
3Wine Wine
8 Scrolls Scrolls
Rain MillRain Mill

01:24
4Leather Leather
4Plant Fiber Plant Fiber
10Wood Wood
3Pigment Pigment
3Wine Wine
8 Scrolls Scrolls


Further Examples and Errors

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

1. product and building:

{{Recipe|Crystalized Dew|Brickyard}}

Yields:

Recipe for Crystalized Dew in the Brickyard.
BuildingIngredient #1 optionsIngredient #2 optionsIngredient #3 optionsProduct
BrickyardBrickyard

00:42
3Herbs Herbs
3Insects Insects
3Resin Resin
3Vegetables Vegetables
4Stone Stone
4Clay Clay
10Storm Water Storm Water
14Clearance Water Clearance Water
18Drizzle Water Drizzle Water
2 Crystalized Dew Crystalized Dew


2. product only

{{Recipe|Pie}}

Yields:

Recipes for Pie.
BuildingIngredient #1 optionsIngredient #2 optionsIngredient #3 optionsProduct
Brick OvenBrick Oven
★★★
01:45
6Flour Flour
3Herbs Herbs
3Meat Meat
3Insects Insects
3Eggs Eggs
3Berries Berries
10 Pie Pie
FurnaceFurnace
★★
02:06
6Flour Flour
4Herbs Herbs
4Meat Meat
4Insects Insects
4Eggs Eggs
4Berries Berries
10 Pie Pie
BakeryBakery
★★
02:06
6Flour Flour
4Herbs Herbs
4Meat Meat
4Insects Insects
4Eggs Eggs
4Berries Berries
10 Pie Pie


3. building only

{{Recipe|building=Scribe}}

Yields:

Recipes in the Scribe.
BuildingIngredient #1 optionsIngredient #2 optionsIngredient #3 optionsProduct
ScribeScribe

01:30
10Wood Wood
3Planks Planks
4Copper Bars Copper Bars
4Crystalized Dew Crystalized Dew
2 Tools Tools
ScribeScribe
★★
02:06
5Grain Grain
5Roots Roots
3Pottery Pottery
2Barrels Barrels
3Waterskins Waterskins
10 Ale Ale
ScribeScribe
★★★
01:03
2Leather Leather
2Plant Fiber Plant Fiber
6Wood Wood
1Pigment Pigment
1Wine Wine
8 Scrolls Scrolls


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

4. with no parameters

{{Recipe}}

Yields:

The Recipe template requires that you specify at least one of the following: product, building, or ingredient.


5. using only one pipe and not specifying that the provided name is the building

{{Recipe|Scribe}}

Yields:

Lua error in Module:RecipeData at line 143: No product found. Please check spelling and any punctuation like an apostrophe: Scribe.


6. asking for products or buildings with no recipes

{{Recipe|Market}}

Yields:

Lua error in Module:RecipeData at line 274: No building found. Please check spelling and any punctuation like an apostrophe: Market.