Template:Construction: Difference between revisions
Added support for Wood |
now adds the ats-resource-list css class to all inner tables for construction |
||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
<includeonly>{{# | <includeonly>{{Resource_stack | ||
|{{#if:{{{Planks|{{{1|}}}}}}|{{{Planks|{{{1|}}}}}} Planks}}|{{#if:{{{Bricks|{{{2|}}}}}}|{{{Bricks|{{{2|}}}}}} Bricks}}|{{#if:{{{Fabric|{{{3|}}}}}}|{{{Fabric|{{{3|}}}}}} Fabric}}|{{#if:{{{Parts|{{{4|}}}}}}|{{{Parts|{{{4|}}}}}} Parts}}|{{#if:{{{Crystalized Dew|}}}|{{{Crystalized Dew|}}} Crystalized Dew}}|{{#if:{{{Wildfire Essence|}}}|{{{Wildfire Essence|}}} Wildfire Essence}}|{{#if:{{{Wood|}}}|{{{Wood|}}} Wood}}|{{#if:{{{Pipes|}}}|{{{Pipes|}}} Pipes}}|classes="ats-resource-list"}}</includeonly><noinclude> | |||
}}</includeonly><noinclude> | |||
== Overview == | == Overview == | ||
| Line 18: | Line 13: | ||
! Parameter !! Type !! Description | ! Parameter !! Type !! Description | ||
|- | |- | ||
| Planks || | | Planks || number || The number of {{rl|Planks}} required. | ||
|- | |- | ||
| Bricks || | | Bricks || number || The number of {{rl|Bricks}} required. | ||
|- | |- | ||
| Fabric || | | Fabric || number || The number of {{rl|Fabric}} required. | ||
|- | |- | ||
| Parts || | | Parts || number || The number of {{rl|Parts}} required. | ||
|- | |- | ||
| Wood || | | Wood || number || The number of {{rl|Wood}} required. This will appear at the top of the table. This must be named, like <code>Wood=</code> | ||
|- | |||
| Crystalized Dew || number || The number of {{rl|Crystalized Dew}} required. This must be named, like <code>Crystalized Dew=</code> | |||
|- | |||
| Pipes || number || The number of {{rl|Pipes}} required. This must be named, like <code>Pipes=</code> | |||
|- | |||
| Wildfire Essence || number || The number of {{rl|Wildfire Essence}} required. This must be named, like <code>Wildfire Essence=</code> | |||
|} | |} | ||
== Examples == | == Examples == | ||
This table shows all possible values. <code><nowiki>{{Construction|Planks=12|Bricks=8|Fabric=4|Parts=2}}</nowiki></code> yields: | This table shows all possible values. <code><nowiki>{{Construction|Planks=12|Bricks=8|Fabric=4|Parts=2|Wood=10|Pipes=4|Crystalized Dew=2|Wildfire Essence=1}}</nowiki></code> yields: | ||
{{Construction|Planks=12|Bricks=8|Fabric=4|Parts=2}} | {{Construction|Planks=12|Bricks=8|Fabric=4|Parts=2|Wood=10|Pipes=4|Crystalized Dew=2|Wildfire Essence=1}} | ||
Alternatively, you do not have to name the parameters. <code><nowiki>{{Construction|12|8|4|2}</nowiki></code> yields the same thing: | Alternatively, you do not have to name some of the parameters. <code><nowiki>{{Construction|12|8|4|2|Wood=10|Pipes=4|Crystalized Dew=2|Wildfire Essence=1}}</nowiki></code> yields the same thing: | ||
{{Construction|12|8|4|2}} | {{Construction|12|8|4|2|Wood=10|Pipes=4|Crystalized Dew=2|Wildfire Essence=1}} | ||
You can also mix naming and not-naming to make it easier to write when skipping over building materials. <code><nowiki>{{Construction|8|Parts=2}}</nowiki></code> yields: {{Construction|8|Parts=2}} | You can also mix naming and not-naming to make it easier to write when skipping over building materials. <code><nowiki>{{Construction|8|Parts=2}}</nowiki></code> yields: {{Construction|8|Parts=2}} | ||
Remember you need to declare the amount of Wood explicitly. This is because <code><nowiki>{{Construction|Wood=10|Parts=3}}</nowiki></code> is much easier to read than <code><nowiki>{{Construction||||3|Wood=10}}</nowiki></code> and affords the ability to declare ''most'' construction requirements with Planks. Here's the result: | Remember you need to declare the amount of Wood, Crystalized Dew, Pipes, and Wildfire Essence explicitly. This is because <code><nowiki>{{Construction|Wood=10|Parts=3}}</nowiki></code> is much easier to read than <code><nowiki>{{Construction||||3|Wood=10}}</nowiki></code> and affords the ability to declare ''most'' construction requirements with Planks. Here's the result: | ||
{{Construction|Wood=10|Parts=3}} | {{Construction|Wood=10|Parts=3}} | ||
== Errors == | == Errors == | ||
A template called without parameters results in a simple error message. | |||
<pre>{{Construction}}</pre> | <pre>{{Construction}}</pre> | ||
Yields: | Yields: | ||
{{Construction}} | {{Construction}} | ||
The template also does not prevent you from mixing both named and unnamed parameters, but the result will be whichever is defined last. | The template also does not prevent you from mixing both named and unnamed parameters, but the result will be whichever is defined last. | ||
| Line 68: | Line 65: | ||
Yields: | Yields: | ||
{{Construction|2|Wood=8}} | {{Construction|2|Wood=8}} | ||
</noinclude> | |||
[[Category:Lua-based templates]]</noinclude> | |||
Latest revision as of 02:13, 26 September 2026
Overview
A template to populate small, well-aligned tables of construction goods.
Parameters
You may elect to name the parameters explicitly (Planks=) or use them in the order specified in the table. The exception is Wood, which must be declared explicitly, but is placed at the beginning of the table.
| Parameter | Type | Description |
|---|---|---|
| Planks | number | The number of |
| Bricks | number | The number of |
| Fabric | number | The number of |
| Parts | number | The number of |
| Wood | number | The number of Wood=
|
| Crystalized Dew | number | The number of Crystalized Dew=
|
| Pipes | number | The number of Pipes=
|
| Wildfire Essence | number | The number of Wildfire Essence=
|
Examples
This table shows all possible values. {{Construction|Planks=12|Bricks=8|Fabric=4|Parts=2|Wood=10|Pipes=4|Crystalized Dew=2|Wildfire Essence=1}} yields:
| 12 | |
| 8 | |
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 10 | |
| 4 |
Alternatively, you do not have to name some of the parameters. {{Construction|12|8|4|2|Wood=10|Pipes=4|Crystalized Dew=2|Wildfire Essence=1}} yields the same thing:
| 12 | |
| 8 | |
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 10 | |
| 4 |
You can also mix naming and not-naming to make it easier to write when skipping over building materials. {{Construction|8|Parts=2}} yields:
| 8 | |
| 2 |
Remember you need to declare the amount of Wood, Crystalized Dew, Pipes, and Wildfire Essence explicitly. This is because {{Construction|Wood=10|Parts=3}} is much easier to read than {{Construction||||3|Wood=10}} and affords the ability to declare most construction requirements with Planks. Here's the result:
| 3 | |
| 10 |
Errors
A template called without parameters results in a simple error message.
{{Construction}}
Yields: [Resource stack needs at least one resource]
The template also does not prevent you from mixing both named and unnamed parameters, but the result will be whichever is defined last.
{{Construction||10|Bricks=12}}
Yields:
| 12 |
Finally, even though no buildings currently require it, this template does permit you to display both Wood and Planks.
{{Construction|2|Wood=8}}
Yields:
| 2 | |
| 8 |


