Template:ResourceHelper: Difference between revisions
Jump to navigation
Jump to search
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> |
Revision as of 02:47, 14 November 2023
What is this?
This is a wrapper around Template:Resource to work better in conjunction with Module:ParseList specifically by Template:ResourceList.
Optional parameters like cost=3
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
{{ResourceHelper | <type>:[count]}}
<>
Denotes mandatory parameters, []
denotes optional parameters.
Refer to Template:Resource for a list of the handled resource types.
Examples
Output | Input |
---|---|
Ki Point | {{ResourceSimple|ki}} |
5Ki Points | {{ResourceSimple|ki:5}} |
(ERROR: Use movement m or movement ft .)Movement |
{{ResourceSimple|movement:30}} |
Action, and 3Ki Points | {{#invoke: ParseList | main | action, ki:3 | useTemplate = ResourceSimple }} |
Bonus action, and(ERROR: Use movement m or movement ft .)Movement
|
{{#invoke: ParseList | main | bonus, movement:10 | useTemplate = ResourceSimple }} |