Template:Recipe: Difference between revisions

From Against the Storm Official Wiki
(improved description; added examples of invalid calls)
(Connecting to the new template modules that are easier to maintain)
Line 1: Line 1:
<includeonly>{{#invoke:RenderRecipe|renderRecipe|product={{{1|{{{product|}}} }}}|building={{{2|{{{building|}}} }}} }}
<includeonly>{{#invoke: Recipe|render
| product= {{{ 1|{{{product|}}} }}}  
| building={{{ 2|{{{building|}}} }}}  
| ingredient={{{ingredient|}}}
}}
</includeonly><noinclude>
</includeonly><noinclude>




<code><nowiki>{{#invoke:RenderRecipe|renderRecipe|product={{{1|{{{product|}}} }}}|building={{{2|{{{building|}}} }}} }}</nowiki></code>
<code><nowiki>{{#invoke: Recipe|render
| product= {{{ 1|{{{product|}}} }}}  
| building={{{ 2|{{{building|}}} }}}  
| ingredient={{{ingredient|}}}
}}</nowiki></code>




This template is used like this:
This template is used like this:
<code><nowiki>{{Recipe|product|building}}</nowiki></code>
<code><nowiki>{{Recipe|product|building|ingredient}}</nowiki></code>





Revision as of 21:44, 5 November 2023


{{#invoke: Recipe|render | product= {{{ 1|{{{product|}}} }}} | building={{{ 2|{{{building|}}} }}} | ingredient={{{ingredient|}}} }}


This template is used like this: {{Recipe|product|building|ingredient}}


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:

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


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


4. With no arguments, {{Recipe}} yields:

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


5. Skipping the double pipe AND not specifying that the provided name is the building in {{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. Mixing naming the arguments and not naming the arguments {{Recipe|product=Eggs|Ranch}} yields:

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


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