count (roll option): Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page Count (roll option) to count (roll option): Converting page titles to lowercase)
m (Text replacement - "source>" to "syntaxhighlight>")
Line 10: Line 10:
[COUNT(num): body]
[COUNT(num): body]
[COUNT(num, separator): body]
[COUNT(num, separator): body]
</source>
</syntaxhighlight>


The ''[[roll.count]]'' variable will take on values from {{code|0}} to ({{code|number of loops - 1}}). The optional separator (default {{code|","}}) is printed between each iteration. Some examples of other useful separators: ''nothing'' {{code|""}}, ''space'' {{code|" "}} and ''break'' {{code|"&lt;br>"}}.
The ''[[roll.count]]'' variable will take on values from {{code|0}} to ({{code|number of loops - 1}}). The optional separator (default {{code|","}}) is printed between each iteration. Some examples of other useful separators: ''nothing'' {{code|""}}, ''space'' {{code|" "}} and ''break'' {{code|"&lt;br>"}}.
Line 18: Line 18:
[h:numHits=3]
[h:numHits=3]
[COUNT(numHits): Damage = Damage + 1d12]
[COUNT(numHits): Damage = Damage + 1d12]
</source>
</syntaxhighlight>


This will iterate the {{code|Damage {{=}} Damage + 1d12}} operation 3 times, separating the result of each iteration with the default separator (a comma). An optional second argument to {{code|COUNT()}} allows the setting of a different separator.
This will iterate the {{code|Damage {{=}} Damage + 1d12}} operation 3 times, separating the result of each iteration with the default separator (a comma). An optional second argument to {{code|COUNT()}} allows the setting of a different separator.

Revision as of 17:09, 14 March 2023

 This article is a stub, you can help the RPTools Wiki project by contributing content to expand this article.

COUNT Option

Introduced: Version 1.3.b41

The COUNT option executes a statement for a specified number of times, storing the number of the current iteration in a variable called roll.count.

Usage

<source lang="mtmacro" line> [COUNT(num): body] [COUNT(num, separator): body] </syntaxhighlight>

The roll.count variable will take on values from 0 to (number of loops - 1). The optional separator (default ",") is printed between each iteration. Some examples of other useful separators: nothing "", space " " and break "<br>".

Example

<source lang="mtmacro" line> [h:numHits=3] [COUNT(numHits): Damage = Damage + 1d12] </syntaxhighlight>

This will iterate the Damage = Damage + 1d12 operation 3 times, separating the result of each iteration with the default separator (a comma). An optional second argument to COUNT() allows the setting of a different separator.