Template:ResourceHelper: Difference between revisions
Jump to navigation
Jump to search
(Changed the input format to "type:count" instead of "count type") |
HiddenDragon (talk | contribs) (Use lvar for locally scoped variables instead) |
||
Line 1: | Line 1: | ||
<includeonly><!-- | <includeonly><!-- | ||
Handle resources in the format of [count] <resource> e.g. "ki:4" or just "ki" | Handle resources in the format of [count] <resource> e.g. "ki:4" or just "ki" | ||
-->{{# | -->{{#lvardef:type|{{ #explode: {{{1}}}|:|0}}}}<!-- | ||
Split parameter into type and count on the : | Split parameter into type and count on the : | ||
-->{{# | -->{{#lvardef:count|{{ #explode: {{{1}}}|:|1}}}}<!-- | ||
-->{{#if: {{# | -->{{#if: {{#lvar: count}} | ||
| {{resource|{{# | | {{resource|{{#lvar: type}}|count={{#lvar: count}}}} | ||
| {{resource|{{# | | {{resource|{{#lvar: type}}}} | ||
}}</includeonly><noinclude> | }}</includeonly><noinclude> | ||
=What is this?= | =What is this?= | ||
Line 24: | Line 24: | ||
! Input | ! Input | ||
|- | |- | ||
|{{ | |{{ResourceHelper|ki}}||<pre>{{ResourceHelper|ki}}</pre> | ||
|- | |- | ||
|{{ | |{{ResourceHelper|ki:5}}||<pre>{{ResourceHelper|ki:5}}</pre> | ||
|- | |- | ||
|{{ | |{{ResourceHelper|movement:30}}||<pre>{{ResourceHelper|movement:30}}</pre> | ||
|- | |- | ||
| {{#invoke: ParseList | main | action, ki:3 | useTemplate = | | {{#invoke: ParseList | main | action, ki:3 | useTemplate = ResourceHelper }} | ||
| <pre>{{#invoke: ParseList | main | action, ki:3 | useTemplate = | | <pre>{{#invoke: ParseList | main | action, ki:3 | useTemplate = ResourceHelper }}</pre> | ||
|- | |- | ||
| {{#invoke: ParseList | main | | {{#invoke: ParseList | main | ||
| bonus, movement:10 | useTemplate = | | bonus, movement:10 | useTemplate = ResourceHelper | ||
}} | }} | ||
| <pre> | | <pre> | ||
{{#invoke: ParseList | main | {{#invoke: ParseList | main | ||
| bonus, movement:10 | useTemplate = | | bonus, movement:10 | useTemplate = ResourceHelper | ||
}} | }} | ||
</pre> | </pre> | ||
|} | |} | ||
</noinclude> | </noinclude> |
Revision as of 08:44, 22 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 | {{ResourceHelper|ki}} |
5Ki Points | {{ResourceHelper|ki:5}} |
(ERROR: Use movement m or movement ft .)Movement |
{{ResourceHelper|movement:30}} |
Action, and 3Ki Points | {{#invoke: ParseList | main | action, ki:3 | useTemplate = ResourceHelper }} |
Bonus action, and(ERROR: Use movement m or movement ft .)Movement
|
{{#invoke: ParseList | main | bonus, movement:10 | useTemplate = ResourceHelper }} |