Template:ResourceHelper: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
(This template will enable using ParseList on resource costs)
 
mNo edit summary
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<includeonly><!--
<includeonly><!--
Handle resources in the format of [count] <resource> e.g. "4 ki" or just "ki"
Handle resources in the format of [count] <resource> e.g. "ki:4" or just "ki"
-->{{#vardefine:param1|{{ #explode: {{{1}}}| |0}}}}<!--
-->{{#lvardef:type|{{ #explode: {{{1}}}|:|0}}}}<!--
Split parameters on whitespace
Split parameter into type and count on the :
-->{{#vardefine:param2|{{ #explode: {{{1}}}| |1}}}}<!--
-->{{#lvardef:count|{{ #explode: {{{1}}}|:|1}}}}<!--
If there are multiple parameters, assume the first value is the count
-->{{#if: {{#lvar: count}}
-->{{#if: {{#var: param2}}
   | {{resource|{{#lvar: type}}|count={{#lvar: count}}}}
   | {{resource|{{#var: param2}}|count={{#var: param1}}}}
   | {{resource|{{#lvar: type}}}}
   | {{resource|{{#var: param1}}}}
}}{{#switch: {{{this is an example|}}}
}}</includeonly><noinclude>
| yes =
=What is this?=
| #default = {{#switch: {{#lvar: type}}
This is a wrapper around [[Template:Resource]] to work better in conjunction with [[Module:ParseList]].
  | bonus = {{Main namespace only|[[Category:Bonus actions]]}}
=Usage=
  | half movement | movement | movement m = {{Main namespace only|[[Category:Movement-expending actions]]}}
<pre>{{Resource | [count] <type>}}</pre>
  | reaction = {{Main namespace only|[[Category:Reactions]]}}
  | action = {{Main namespace only|[[Category:Actions]]}}
  | #default =
  }}}}</includeonly><noinclude>{{Documentation|content=
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 ==
<pre>{{ResourceHelper | <type>:[count]}}</pre>
----
----
<br/><code><></code> Denotes mandatory parameters, <code>[]</code> denotes mandatory parameters.
<br/><code><></code> Denotes mandatory parameters, <code>[]</code> denotes optional parameters.


Refer to [[Template:Resource]] for a list of the handled resource types.
Refer to [[Template:Resource]] for a list of the handled resource types.


=Examples=
== Examples ==
{| class="wikitable mw-collapsible"
{{Template demo
! Output
| style = table
! Input
| <nowiki>{{ResourceHelper|ki}}</nowiki>
|-
| <nowiki>{{ResourceHelper|ki:5}}</nowiki>
|{{ResourceSimple|ki}}||<pre>{{ResourceSimple|ki}}</pre>
| <nowiki>{{ResourceHelper|movement m:30}}</nowiki>
|-
}}
|{{ResourceSimple|5 ki}}||<pre>{{ResourceSimple|5 ki}}</pre>
 
|-
}}
|{{ResourceSimple|30 movement}}||<pre>{{ResourceSimple|30 movement}}</pre>
[[Category:Templates]]
|-
| {{#invoke: ParseList | main | action, 3 ki | useTemplate = ResourceSimple }}
| <pre>{{#invoke: ParseList | main | action, 3 ki | useTemplate = ResourceSimple }}</pre>
|}
</noinclude>
</noinclude>

Latest revision as of 21:53, 19 January 2025

Template documentation

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

Markup Renders as
{{ResourceHelper|ki}}
Ki Point
{{ResourceHelper|ki:5}}
5Ki Points
{{ResourceHelper|movement m:30}}
30 m / 100 ftMovement