Template:Recipe: Difference between revisions

From Against the Storm Official Wiki
(Revised the documentation, now includes how to use the ingredient parameter)
(BIG UPDATE! Updated to use new RecipeController. Updated doc to include services and examples)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#invoke: Recipe|render
<includeonly>{{#invoke: RecipeController | renderRecipe
| product= {{{ 1|{{{product|}}} }}}  
    | product = {{{product| {{{1|}}} }}}  
| building={{{ 2|{{{building|}}} }}}  
    | building = {{{building| {{{2|}}} }}}  
| ingredient={{{ingredient|}}}
    | ingredient = {{{ingredient|}}}
    | display = {{{display|}}}
}}
}}
</includeonly><noinclude>
</includeonly><noinclude>


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


== Overview ==
== 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.
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 (or service). Optionally, outputs just a list of buildings (or products or services at a building) with their efficiency stars.
 
=== Links to Resource Pages ===
 
Links within the table point to the product's or service's page and the anchor corresponding to its location in the table. Goods in ingredients columns will point to the recipes where that good is a product, so you can see where it comes from. Goods in the product column will point to the recipes where that good is an ingredient, so you can see where it can be used.


== Parameters ==
== 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.
At least one of these is required. If the names provided are not spelled correctly (including punctuation), matching their in-game names, the recipe will return an error.


{| class="wikitable"
{| class="wikitable"
! Parameter !! Type !! Description
! 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.
| product || string || The name of the product or service 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.
| 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.
| ingredient || string || The name of an ingredient in a recipe. May result in a very long table.
|-
| 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 or service names or icons. Or, if you've specified the building, it displays a list of products with their efficiency stars. Useful for populating larger tables or between paragraphs where displaying the entire recipe isn't relevant.
|}
|}


== Errors ==
== 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.
When a product, service, 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:'''
'''Example:'''


Broken: <code><nowiki>{{Recipe|building=BrickOven}}</nowiki></code>
Broken: <code><nowiki>{{Recipe|building=Alchemists' Hut}}</nowiki></code>


{{Recipe|building=BrickOven}}
{{Recipe|building=Alchemists' Hut}}


Fixed: <code><nowiki>{{Recipe|building=Brick Oven}}</nowiki></code>
Fixed: <code><nowiki>{{Recipe|building=Alchemist's Hut}}</nowiki></code>


{{Recipe|building=Brick Oven}}
{{Recipe|building=Alchemist's Hut}}


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.
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.
Line 45: Line 52:
=== Basic Usage for Products and Buildings ===
=== Basic Usage for Products and Buildings ===


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


<pre>{{Recipe|Crystalized Dew|Brickyard}}</pre>
<pre>{{Recipe|Crystalized Dew|Brickyard}}</pre>
Line 52: Line 59:


{{Recipe|Crystalized Dew|Brickyard}}
{{Recipe|Crystalized Dew|Brickyard}}
Alternatively, for a service building:
<pre>{{Recipe|Leisure|Tavern}}</pre>
Yields:
{{Recipe|Leisure|Tavern}}


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


{| 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
|-
|-
| product and building
| product (or service) 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 exactly one row.
| A table with exactly one row.
|-
|-
| product only
| product (or service) 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||Market}}</nowiki></code> ''(note the double pipe)'' <br> <code><nowiki>{{Recipe|building=Market}}</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 service provided by the '''Market.'''
|-
| product (or service), 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}}
|}
|}


=== Ingredients ===
=== 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.
Unlike when specifying the product (or service) and/or building, when you specify the ingredient, you explicitly must name the parameter with <code>ingredient=</code> in the template. Currently, you cannot select both a product and an ingredient (for example, all recipes where Berries are the ingredient and Pie is the product), because this is redundant with the product parameter by itself (since there is currently only one arrangement of ingredients and options that will make a product).


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


<pre>{{Recipe|ingredient=Wine}}</pre>
<pre>{{Recipe|ingredient=Wine}}</pre>
Yields:
{{Recipe|ingredient=Wine}}
<pre>{{Recipe|building=Lumber Mill|ingredient=Wine}}</pre>
<pre>{{Recipe|building=Lumber Mill|ingredient=Wine}}</pre>


Both result in:
Yields:
 
{{Recipe|building=Lumber Mill|ingredient=Wine}}


{{Recipe|ingredient=Wine}}


=== Further Examples and Errors ===
=== Further Examples and Errors ===
Line 108: Line 134:
3. building only
3. building only


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


Yields:
Yields:


{{Recipe|building=Scribe}}
{{Recipe|Crystalized Dew|display=list}}
 
5 with the output override but specifying a building
 
<pre>{{Recipe|building=Beanery|display=list}}</pre>
 
Yields:
 
{{Recipe|building=Beanery|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
6. with no parameters


<pre>{{Recipe}}</pre>
<pre>{{Recipe}}</pre>
Line 124: Line 166:
{{Recipe}}
{{Recipe}}


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


<pre>{{Recipe|Scribe}}</pre>  
<pre>{{Recipe|Scribe}}</pre>  
Line 132: Line 174:
{{Recipe|Scribe}}
{{Recipe|Scribe}}


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


<pre>{{Recipe|Market}}</pre>
<pre>{{Recipe|building=Small Warehouse}}</pre>


Yields:
Yields:


{{Recipe|building=Market}}
{{Recipe|building=Small Warehouse}}
</noinclude>
</noinclude>

Latest revision as of 03:38, 27 November 2023


Generates recipe tables. Use this wherever you need to show how to use Goods, Services, 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 (or service). Optionally, outputs just a list of buildings (or products or services at a building) with their efficiency stars.

Links to Resource Pages

Links within the table point to the product's or service's page and the anchor corresponding to its location in the table. Goods in ingredients columns will point to the recipes where that good is a product, so you can see where it comes from. Goods in the product column will point to the recipes where that good is an ingredient, so you can see where it can be used.

Parameters

At least one of these is required. 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 or service 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. May result in a very long table.
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 or service names or icons. Or, if you've specified the building, it displays a list of products with their efficiency stars. Useful for populating larger tables or between paragraphs where displaying the entire recipe isn't relevant.

Errors

When a product, service, 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}}

No recipes found at building: Alchemists' Hut.


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

3 recipes in the Alchemist's Hut.
BuildingEfficiencyIngredient #1Ingredient #2Ingredient #3Product
★★
00:42
2
2
2
2
3
3
8
12
16
2
★★
02:06
3
3
3
3
3
3
4
5
2
2
10
Tea Tea
★★
01:24
3
3
3
3
3
3
10
Wine Wine


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 or service, in one building:

{{Recipe|Crystalized Dew|Brickyard}}

Yields:

1 recipe in the Brickyard for Crystalized Dew.
BuildingEfficiencyIngredient #1Ingredient #2Ingredient #3Product

00:42
3
3
3
3
4
4
10
14
18
2


Alternatively, for a service building:

{{Recipe|Leisure|Tavern}}

Yields:

1 recipe in the Tavern for Leisure.
BuildingEfficiencyIngredientService

1
Ale Ale
1


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

Parameter(s) Example(s) Expected outcome
no parameters {{Recipe}} an error
product (or service) and building {{Recipe|Crystalized Dew|Brickyard}}
{{Recipe|product=Crystalized Dew|building=Brickyard}}
A table with exactly one row.
product (or service) only {{Recipe|Pie}}
{{Recipe|product=Pie}}
A table with several rows, one for each building in which Pie can be produced.
building only {{Recipe||Market}} (note the double pipe)
{{Recipe|building=Market}}
A table with several rows, one for each service provided by the Market.
product (or service), but with output override {{Recipe|Crystalized Dew|display=list}} A short list of buildings and their efficiency stars that easily fit within another table:

Ingredients

Unlike when specifying the product (or service) and/or building, when you specify the ingredient, you explicitly must name the parameter with ingredient= in the template. Currently, you cannot select both a product and an ingredient (for example, all recipes where Berries are the ingredient and Pie is the product), because this is redundant with the product parameter by itself (since there is currently only one arrangement of ingredients and options that will make a product).

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

{{Recipe|ingredient=Wine}}

Yields:

5 recipes using Wine.
BuildingEfficiencyIngredient #1Ingredient #2Product or Service

01:24
4
4
10
3
3
8

01:24
4
4
10
3
3
8

01:24
4
4
10
3
3
8
★★★
01:03
2
2
6
1
1
8
★★★
01:03
2
2
6
1
1
8

00:42
5
5
5
5
5
Ale Ale
5
Tea Tea
2
★★
00:42
4
4
4
4
4
Ale Ale
4
Tea Tea
2
★★
00:42
4
4
4
4
4
Ale Ale
4
Tea Tea
2

1
1

1
1

1
1

1
1


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

Yields:

1 recipes using Wine in the Lumber Mill.
BuildingEfficiencyIngredient #1Ingredient #2Product

01:24
4
4
10
3
3
8


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:

1 recipe in the Brickyard for Crystalized Dew.
BuildingEfficiencyIngredient #1Ingredient #2Ingredient #3Product

00:42
3
3
3
3
4
4
10
14
18
2


2. product only

{{Recipe|Pie}}

Yields:

2 recipes for Pie.
BuildingEfficiencyIngredient #1Ingredient #2Product
★★
02:06
6
4
4
4
4
4
10
Pie Pie
★★
02:06
6
4
4
4
4
4
10
Pie Pie
★★★
01:45
6
3
3
3
3
3
10
Pie Pie


3. building only

{{Recipe|building=Market}}

Yields:

2 recipes in the Market.
BuildingEfficiencyIngredientService

1
1

1
Tea Tea
1


4. with the output override

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

Yields:


5 with the output override but specifying a building

{{Recipe|building=Beanery|display=list}}

Yields:


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

6. with no parameters

{{Recipe}}

Yields:

Unknown parameter in Recipe template.


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

{{Recipe|Scribe}}

Yields:

No recipes found for product: Scribe.


8. asking for products or buildings with no recipes

{{Recipe|building=Small Warehouse}}

Yields:

No recipes found at building: Small Warehouse.