Template:Construction: Difference between revisions

From Against the Storm Official Wiki
(Making a new template for construction goods since we use this all over the place)
 
m (→‎Examples: fixed wrong example)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><table>{{#if:{{{1|}}}|<tr><td>'''{{{1}}}'''</td><td>{{rl|Planks|med}}</td></tr>}}
<includeonly>{{#invoke: Construction| renderTable
{{#if:{{{Planks|}}}|<tr><td>'''{{{Planks}}}'''</td><td>{{rl|Planks|med}}</td></tr>}}
    | planks = {{{Planks| {{{1|}}} }}}
{{#if:{{{2|}}}|<tr><td>'''{{{2}}}'''</td><td>{{rl|Bricks|med}}</td></tr>}}
    | bricks = {{{Bricks| {{{2|}}} }}}
{{#if:{{{Bricks|}}}|<tr><td>'''{{{Bricks}}}'''</td><td>{{rl|Bricks|med}}</td></tr>}}
    | fabric = {{{Fabric| {{{3|}}} }}}
{{#if:{{{3|}}}|<tr><td>'''{{{3}}}'''</td><td>{{rl|Fabric|med}}</td></tr>}}
    | parts =  {{{Parts| {{{4|}}} }}}
{{#if:{{{Fabric|}}}|<tr><td>'''{{{Fabric}}}'''</td><td>{{rl|Fabric|med}}</td></tr>}}
    | wood =  {{{Wood|}}}
{{#if:{{{4|}}}|<tr><td>'''{{{4}}}'''</td><td>{{rl|Parts|med}}</td></tr>}}
    | pipes =  {{{Pipes|}}}
{{#if:{{{Parts|}}}|<tr><td>'''{{{Parts}}}'''</td><td>{{rl|Parts|med}}</td></tr>}}</table></includeonly><noinclude>
}}</includeonly><noinclude>


== Overview ==
== Overview ==


A template to populate small, well-aligned tables of construction goods.
A template to populate small, well-aligned tables of construction goods.


== Parameters ==
== Parameters ==


You may elect to name the parameters explicitly (<code>Planks=</code>) or use them in the order specified in the table:
You may elect to name the parameters explicitly (<code>Planks=</code>) 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.


{| class="wikitable"
{| class="wikitable"
! Parameter !! Type !! Description
! Parameter !! Type !! Description
|-
|-
| Planks || Number || The number of {{rl|Planks}} required.
| Planks || number || The number of {{rl|Planks}} required.
|-
|-
| Bricks || Number || The number of {{rl|Bricks}} required.
| Bricks || number || The number of {{rl|Bricks}} required.
|-
|-
| Fabric || Number || The number of {{rl|Fabric}} required.
| Fabric || number || The number of {{rl|Fabric}} required.
|-
|-
| Parts || Number || The number of {{rl|Parts}} required.
| Parts || number || The number of {{rl|Parts}} required.
|-
| 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>
|-
| Pipes || number || The number of {{rl|Pipes}} required. This must be named, like <code>Pipes=</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}}</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}}


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}}</nowiki></code> yields the same thing:
{{Construction|12|8|4|2}}
{{Construction|12|8|4|2|Wood=10|Pipes=4}}


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 and Pipes 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}}


== Errors ==
== Errors ==
Line 51: Line 58:
(It's there, but it's a blank table.)
(It's there, but it's a blank table.)


The template also does not prevent you from mixing both named and unnamed parameters, but the result will be confusing to readers.
The template also does not prevent you from mixing both named and unnamed parameters, but the result will be whichever is defined last.


<pre>{{Construction||10|Bricks=12}}</pre>
<pre>{{Construction||10|Bricks=12}}</pre>
Line 57: Line 64:
Yields:
Yields:
{{Construction||10|Bricks=12}}
{{Construction||10|Bricks=12}}
</noinclude>
 
Finally, even though no buildings currently require it, this template does permit you to display both Wood and Planks.
 
<pre>{{Construction|2|Wood=8}}</pre>
 
Yields:
{{Construction|2|Wood=8}}
 
[[Category:Lua-based templates]]</noinclude>

Latest revision as of 20:06, 5 October 2024


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 Planks Planks required.
Bricks number The number of Bricks Bricks required.
Fabric number The number of Fabric Fabric required.
Parts number The number of Parts Parts required.
Wood number The number of Wood Wood required. This will appear at the top of the table. This must be named, like Wood=
Pipes number The number of Pipes Pipes required. This must be named, like Pipes=

Examples

This table shows all possible values. {{Construction|Planks=12|Bricks=8|Fabric=4|Parts=2|Wood=10|Pipes=4}} yields:

10Wood Wood
12Planks Planks
8Bricks Bricks
4Fabric Fabric
2Parts Parts
4Pipes Pipes

Alternatively, you do not have to name some of the parameters. {{Construction|12|8|4|2|Wood=10|Pipes=4}} yields the same thing:

10Wood Wood
12Planks Planks
8Bricks Bricks
4Fabric Fabric
2Parts Parts
4Pipes Pipes

You can also mix naming and not-naming to make it easier to write when skipping over building materials. {{Construction|8|Parts=2}} yields:

8Planks Planks
2Parts Parts

Remember you need to declare the amount of Wood and Pipes 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:

10Wood Wood
3Parts Parts

Errors

This template does not result in any errors. However, there is no use for a template called without parameters.

{{Construction}}

Yields:

(It's there, but it's a blank table.)

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:

12Bricks Bricks

Finally, even though no buildings currently require it, this template does permit you to display both Wood and Planks.

{{Construction|2|Wood=8}}

Yields:

8Wood Wood
2Planks Planks