RPTools

Personal tools
From MapToolDoc

getMatchingProperties

Contents

getMatchingProperties() Function

Introduced in version 1.3b54

Returns a String List or JSON Array with names of the Token Properties on a specific Token that match the given pattern.

Usage

  1. getMatchingProperties(pattern)
  1. getMatchingProperties(pattern, delim)
  1. getMatchingProperties(pattern, delim, id)

Parameters

  • pattern - A regular expression(regex) that represents the pattern the properties should match.
  • delim - The delimiter used in the String List that is returned, defaults to ",". Returns a JSON Array if "json" is specified.
  • id - The token id of the token that is checked for properties that match the given pattern, defaults to the Current Token.  Note: This parameter can only be used in a Trusted Macro

Examples

Say you wanted to keep an inventory list for the Token you could prefix all of your inventory properties with Inv:Category:. For example Inv:Weapon:Longsword.

Then to loop through all of the inventory properties you could use

  1. [foreach(item, getMatchingProperties("Inv:.*")): {
  2.     <!-- Do something really exciting here -->
  3. }]

Or the following to loop through all the weapons

  1. [foreach(item, getMatchingProperties("Inv:Weapon:.*")): {
  2.     <!-- Do something really exciting here -->
  3. }]

Or even all the armor and all the shields.

  1. [foreach(item, getMatchingProperties("Inv:(Armor|Shield):.*")): {
  2.     <!-- Do something really exciting here -->
  3. }]

See Also

getMatchingLibProperties() getPropertyNames()