foreach (roll option): Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Redirect pending split of article.)
 
mNo edit summary
Line 1: Line 1:
#REDIRECT [[Macros:Branching and Looping]]
{{stub}}
===FOREACH Option===
 
'''Introduced''': Version 1.3.b46
 
Iterates over the contents of a string list in the format "''item1, item2, item3''"
 
====Usage====
<source lang="mtmacro" line>
[FOREACH(var, list): body]
[FOREACH(var, list, output_separator): body]
[FOREACH(var, list, output_separator, list_separator): body]
</source>
 
====Example====
<source lang="mtmacro" line>
[h: enemyList="Orcs, Goblins, Ogres, Trolls"]
[FOREACH(enemy, enemyList, "<br>"): "You really hate " + enemy]
</source>
 
Outputs
You really hate Orcs
You really hate Goblins
You really hate Ogres
You really hate Trolls
 
[[Category:Roll Option]]
[[Category:Roll Option]]
[[Category:Looping Roll Option]]
[[Category:Looping Roll Option]]

Revision as of 04:13, 5 April 2009

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

FOREACH Option

Introduced: Version 1.3.b46

Iterates over the contents of a string list in the format "item1, item2, item3"

Usage

[FOREACH(var, list): body]
[FOREACH(var, list, output_separator): body]
[FOREACH(var, list, output_separator, list_separator): body]

Example

[h: enemyList="Orcs, Goblins, Ogres, Trolls"]
[FOREACH(enemy, enemyList, "<br>"): "You really hate " + enemy]

Outputs

You really hate Orcs
You really hate Goblins
You really hate Ogres
You really hate Trolls