7,292
editsAd placeholder
Template:ResourceHelper: Difference between revisions
Jump to navigation
Jump to search
Changed the input format to "type:count" instead of "count type"
m (NtCarlson moved page Template:ResourceSimple to Template:ResourceHelper: More appropriate name for helper template that isn't intended be called directly) |
(Changed the input format to "type:count" instead of "count type") |
||
Line 1: | Line 1: | ||
<includeonly><!-- | <includeonly><!-- | ||
Handle resources in the format of [count] <resource> e.g. "4 | Handle resources in the format of [count] <resource> e.g. "ki:4" or just "ki" | ||
-->{{#vardefine: | -->{{#vardefine:type|{{ #explode: {{{1}}}|:|0}}}}<!-- | ||
Split | Split parameter into type and count on the : | ||
-->{{#vardefine: | -->{{#vardefine:count|{{ #explode: {{{1}}}|:|1}}}}<!-- | ||
-->{{#if: {{#var: count}} | |||
-->{{#if: {{#var: | | {{resource|{{#var: type}}|count={{#var: count}}}} | ||
| {{resource|{{#var: | | {{resource|{{#var: type}}}} | ||
| {{resource|{{#var: | |||
}}</includeonly><noinclude> | }}</includeonly><noinclude> | ||
=What is this?= | =What is this?= | ||
This is a wrapper around [[Template:Resource]] to work better in conjunction with [[Module:ParseList]] specifically by [[Template:ResourceList]]. | This is a wrapper around [[Template:Resource]] to work better in conjunction with [[Module:ParseList]] specifically by [[Template:ResourceList]]. | ||
Optional parameters like <code>cost=3</code> do not work when applying a template to a list with ParseList, so this template enables an alternative syntax that can be used with ParseList. | |||
=Usage= | =Usage= | ||
<pre>{{ | <pre>{{ResourceHelper | <type>:[count]}}</pre> | ||
---- | ---- | ||
<br/><code><></code> Denotes mandatory parameters, <code>[]</code> denotes optional parameters. | <br/><code><></code> Denotes mandatory parameters, <code>[]</code> denotes optional parameters. | ||
Line 25: | Line 26: | ||
|{{ResourceSimple|ki}}||<pre>{{ResourceSimple|ki}}</pre> | |{{ResourceSimple|ki}}||<pre>{{ResourceSimple|ki}}</pre> | ||
|- | |- | ||
|{{ResourceSimple|5 | |{{ResourceSimple|ki:5}}||<pre>{{ResourceSimple|ki:5}}</pre> | ||
|- | |- | ||
|{{ResourceSimple|30 | |{{ResourceSimple|movement:30}}||<pre>{{ResourceSimple|movement:30}}</pre> | ||
|- | |- | ||
| {{#invoke: ParseList | main | action, 3 | | {{#invoke: ParseList | main | action, ki:3 | useTemplate = ResourceSimple }} | ||
| <pre>{{#invoke: ParseList | main | action, 3 | | <pre>{{#invoke: ParseList | main | action, ki:3 | useTemplate = ResourceSimple }}</pre> | ||
|- | |- | ||
| {{#invoke: ParseList | main | | {{#invoke: ParseList | main | ||
| bonus, 10 | | bonus, movement:10 | useTemplate = ResourceSimple | ||
}} | }} | ||
| <pre> | | <pre> | ||
{{#invoke: ParseList | main | {{#invoke: ParseList | main | ||
| bonus, 10 | | bonus, movement:10 | useTemplate = ResourceSimple | ||
}} | }} | ||
</pre> | </pre> | ||
|} | |} | ||
</noinclude> | </noinclude> |