Template:ResourceHelper: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
(Changed the input format to "type:count" instead of "count type")
(Added guards to try to prevent auto-categorization from applying when it shouldn't)
 
(6 intermediate revisions by 2 users not shown)
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"
-->{{#vardefine:type|{{ #explode: {{{1}}}|:|0}}}}<!--
-->{{#lvardef:type|{{ #explode: {{{1}}}|:|0}}}}<!--
Split parameter into type and count on the :
Split parameter into type and count on the :
-->{{#vardefine:count|{{ #explode: {{{1}}}|:|1}}}}<!--
-->{{#lvardef:count|{{ #explode: {{{1}}}|:|1}}}}<!--
-->{{#if: {{#var: count}}
-->{{#if: {{#lvar: count}}
   | {{resource|{{#var: type}}|count={{#var: count}}}}
   | {{resource|{{#lvar: type}}|count={{#lvar: count}}}}
   | {{resource|{{#var: type}}}}
   | {{resource|{{#lvar: type}}}}
}}</includeonly><noinclude>
}}{{#switch: {{{this is an example|}}}
| yes =
| #default = {{#switch: {{#lvar: type}}
  | bonus = {{Main namespace only|[[Category:Bonus actions]]}}
  | half movement | movement | movement m = {{Main namespace only|[[Category:Movement-expending actions]]}}
  | reaction = {{Main namespace only|[[Category:Reactions]]}}
  | action = {{Main namespace only|[[Category:Actions]]}}
  | #default =
  }}}}</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]].
Line 24: Line 32:
! Input
! Input
|-
|-
|{{ResourceSimple|ki}}||<pre>{{ResourceSimple|ki}}</pre>
|{{ResourceHelper|ki|this is an example=yes}}||<pre>{{ResourceHelper|ki}}</pre>
|-
|-
|{{ResourceSimple|ki:5}}||<pre>{{ResourceSimple|ki:5}}</pre>
|{{ResourceHelper|ki:5|this is an example=yes}}||<pre>{{ResourceHelper|ki:5}}</pre>
|-
|-
|{{ResourceSimple|movement:30}}||<pre>{{ResourceSimple|movement:30}}</pre>
|{{ResourceHelper|movement m:30|this is an example=yes}}||<pre>{{ResourceHelper|movement m:30}}</pre>
|-
|-
| {{#invoke: ParseList | main | action, ki:3 | useTemplate = ResourceSimple }}
| <pre>{{#invoke: ParseList | main | action, ki:3 | useTemplate = ResourceSimple }}</pre>
|-
| {{#invoke: ParseList | main
  | bonus, movement:10 | useTemplate = ResourceSimple
}}
| <pre>
{{#invoke: ParseList | main
  | bonus, movement:10 | useTemplate = ResourceSimple
}}
</pre>
|}
|}
</noinclude>
</noinclude>

Latest revision as of 17:07, 2 October 2024

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}}
30 m / 100 ftMovement
{{ResourceHelper|movement m:30}}