Template:Recipe: Difference between revisions

From Against the Storm Official Wiki
(moving the check for "list" into the lua code; the template can't handle it correctly)
(Adding documentation for output override)
Line 25: Line 25:
| 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.
| 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.
|-
|-
| display || "list" || If <code>display=list</code> is present at the end of the template call, it overrides the use of the wikitable displaying the recipe. Instead, it will produce a list of buildings with their efficiency stars, each on their own line. Useful for populating larger tables where displaying the entire recipe isn't relevant.
| display || "list" || If <code>display=list</code> is present at the end of the template call, it overrides the default use of a wikitable to display the recipe. Instead, it will produce a list of buildings with their efficiency stars, each on their own line, without any ingredients or product names or icons. Useful for populating larger tables where displaying the entire recipe isn't relevant.
|}
|}


Line 59: Line 59:


{| class="wikitable mw-collapsible"
{| class="wikitable mw-collapsible"
! Argument !! Examples !! Expected outcome
! Parameter(s) !! Example(s) !! Expected outcome
|-
|-
| no parameters || <code><nowiki>{{Recipe}}</nowiki></code> || an error
| no parameters || <code><nowiki>{{Recipe}}</nowiki></code> || an error
Line 74: Line 74:
|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.'''
|-
| product, 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}}
|}
|}


Line 116: Line 121:


{{Recipe|building=Scribe}}
{{Recipe|building=Scribe}}
4. with the output override
<pre>{{Recipe|Crystalized Dew|display=list}}</pre>
Yields:
{{Recipe|Crystalized Dew|display=list}}


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
5. with no parameters


<pre>{{Recipe}}</pre>
<pre>{{Recipe}}</pre>
Line 127: Line 140:
{{Recipe}}
{{Recipe}}


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


<pre>{{Recipe|Scribe}}</pre>  
<pre>{{Recipe|Scribe}}</pre>  
Line 135: Line 148:
{{Recipe|Scribe}}
{{Recipe|Scribe}}


6. asking for products or buildings with no recipes
7. asking for products or buildings with no recipes


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

Revision as of 05:27, 11 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. Optionally, outputs just a list of buildings with their efficiency stars.

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.
display "list" If display=list is present at the end of the template call, it overrides the default use of a wikitable to display the recipe. Instead, it will produce a list of buildings with their efficiency stars, each on their own line, without any ingredients or product names or icons. Useful for populating larger tables where displaying the entire recipe isn't relevant.

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=Alchemists' Hut}}

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


Fixed: {{Recipe|building=Alchemist's Hut}}

Recipes in the Alchemist's Hut.
BuildingIngredient #1 optionsIngredient #2 optionsIngredient #3 optionsProduct
Alchemist's HutAlchemist's Hut
★★
02:06
3Herbs Herbs
3Dye Dye
3Resin Resin
3Mushrooms Mushrooms
3Roots Roots
3Drizzle Water Drizzle Water
4Clearance Water Clearance Water
5Storm Water Storm Water
3Pottery Pottery
2Barrels Barrels
3Waterskins Waterskins
10 Tea Tea
Alchemist's HutAlchemist's Hut
★★
01:24
3Berries Berries
3Mushrooms Mushrooms
3Reed Reed
3Pottery Pottery
3Barrels Barrels
3Waterskins Waterskins
10 Wine Wine
Alchemist's HutAlchemist's Hut
★★
00:42
2Herbs Herbs
2Insects Insects
2Resin Resin
2Vegetables Vegetables
2Algae Algae
3Stone Stone
3Clay Clay
8Storm Water Storm Water
12Clearance Water Clearance Water
16Drizzle Water Drizzle Water
2 Crystalized Dew Crystalized Dew


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
3Algae Algae
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.

Parameter(s) Example(s) 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.
product, but with output override {{Recipe|Crystalized Dew|display=list}} A short list of buildings and their efficiency stars that easily fit within another table:
Beanery (★)
Brickyard (★)
Alchemist's Hut (★★)

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
Lumber MillLumber Mill

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

01:24
4Leather Leather
4Plant Fiber Plant Fiber
10Wood Wood
3Dye Dye
3Wine Wine
8 Scrolls Scrolls
Flawless CooperageFlawless Cooperage
★★★
00:28
3Wine Wine
3Training Gear Training Gear
3Incense Incense
3Scrolls Scrolls
3Ale Ale
3Tea Tea
2 Pack of Luxury Goods Pack of Luxury Goods
PantryPantry
★★
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
CooperageCooperage

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
1Dye Dye
1Wine Wine
8 Scrolls Scrolls
Flawless Rain MillFlawless Rain Mill
★★★
01:03
2Leather Leather
2Plant Fiber Plant Fiber
6Wood Wood
1Dye Dye
1Wine Wine
8 Scrolls Scrolls
ArtisanArtisan
★★
01:24
3Leather Leather
3Plant Fiber Plant Fiber
8Wood Wood
2Dye Dye
2Wine 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
3Algae Algae
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
SmelterSmelter

02:06
6Flour Flour
5Herbs Herbs
5Meat Meat
5Insects Insects
5Eggs Eggs
5Berries Berries
5Fish Fish
10 Pie Pie
Flawless SmelterFlawless Smelter
★★★
01:45
6Flour Flour
3Herbs Herbs
3Meat Meat
3Insects Insects
3Eggs Eggs
3Berries Berries
3Fish Fish
10 Pie Pie
PantryPantry
★★
02:06
6Flour Flour
4Herbs Herbs
4Meat Meat
4Insects Insects
4Eggs Eggs
4Berries Berries
4Fish Fish
10 Pie Pie
FurnaceFurnace
★★
02:06
6Flour Flour
4Herbs Herbs
4Meat Meat
4Insects Insects
4Eggs Eggs
4Berries Berries
4Fish Fish
10 Pie Pie
BakeryBakery
★★
02:06
6Flour Flour
4Herbs Herbs
4Meat Meat
4Insects Insects
4Eggs Eggs
4Berries Berries
4Fish Fish
10 Pie Pie


3. building only

{{Recipe|building=Scribe}}

Yields:

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

02:06
6Grain Grain
6Roots Roots
3Pottery Pottery
2Barrels Barrels
3Waterskins Waterskins
10 Ale Ale
ScribeScribe
★★★
01:03
2Leather Leather
2Plant Fiber Plant Fiber
6Wood Wood
1Dye Dye
1Wine Wine
8 Scrolls Scrolls
ScribeScribe
★★
00:42
6Dye Dye
6Oil Oil
4Flour Flour
4Pottery Pottery
4Barrels Barrels
4Waterskins Waterskins
2 Pack of Trade Goods Pack of Trade Goods


4. with the output override

{{Recipe|Crystalized Dew|display=list}}

Yields:

Beanery (★)
Brickyard (★)
Alchemist's Hut (★★)


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

5. with no parameters

{{Recipe}}

Yields:

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


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


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