getPropertyNames: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
(Applied Template:MacroFunction)
Line 1: Line 1:
==Function getPropertyNames==
{{MacroFunction
 
|name=getPropertyNames
 
|description=
Returns a list containing the names of the names of the [[Token:property|properties]] on the [[Token:Current Token|Current Token]].  
Returns a list containing the names of the names of the [[Token:property|properties]] on the [[Token:Current Token|Current Token]].  
The type of the value returned depends on the delimiter parameter.  
The type of the value returned depends on the delimiter parameter.  
* If the delimiter is not specified then a [[Macros:string list|string list]] is returned with the default value of ',' is used.
* If the delimiter is not specified then a [[Macros:string list|string list]] is returned with the default value of {{code|","}} is used.
* If the delimiter ''"json"'' then a [[Macros:json array|json array]] is returned. '''(as of MapTool 1.3b49)'''
* If the delimiter {{code|json}} then a [[Macros:json array|json array]] is returned. '''(as of MapTool 1.3b49)'''
* Otherwise a [[Macros:string list|string list]] is returned with the delimiter passed in.
* Otherwise a [[Macros:string list|string list]] is returned with the delimiter passed in.


 
|usage=
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: names = getPropertyNames()]
[h: names = getPropertyNames()]
[h: names = getPropertyNames(delim)]
[h: names = getPropertyNames(delim)]
</source>
</source>
delim is the delimiter used to separate the values in the  [[Macros:string list|string list]] which defaults to ',' if not specified.
{{code|delim}} is the delimiter used to separate the values in the  [[Macros:string list|string list]] which defaults to {{code|","}} if not specified.
 


===Examples===
|example=
To display the names of all of the [[Token:property|properties]] on the current [[Token:token|token]] use.
To display the names of all of the [[Token:property|properties]] on the current [[Token:token|token]] use.
<source lang="mtmacro" line>
<source lang="mtmacro" line>
Line 22: Line 21:
[foreach(name, names, "<br>"): name]
[foreach(name, names, "<br>"): name]
</source>
</source>
 
}}
===Notes===
===Notes===
 
When token properties are created during campaign, they are persistent in the MapTool campaign, regardless of whether they are editable in the Edit Token window. In other words, even though a property is removed from the campaign properties, it remains available in the MapTool code.  ''getPropertyNames()'' will return ''all'' token properties that exist or have ever existed in the particular campaign, even if users cannot directly edit those properties (''i.e.'', they do not appear in the token's properties when you double click on a token). To get only properties that are currently visible and editable, use [[getAllPropertyNames|getAllPropertyNames()]].
When token properties are created during campaign, they are persistent in the MapTool campaign, regardless of whether they are editable in the Edit Token window. In other words, even though a property is removed from the campaign properties, it remains available in the MapTool code.  ''getPropertyNames()'' will return ''all'' token properties that exist or have ever existed in the particular campaign, even if users cannot directly edit those properties (''i.e.'', they do not appear in the token's properties when you double click on a token). To get only properties that are currently visible and editable, use [[Macros:Functions:getAllPropertyNames|getAllPropertyNames()]].
[[Category:Token Function]]

Revision as of 03:33, 8 March 2009

getPropertyNames() Function

Returns a list containing the names of the names of the properties on the Current Token.

The type of the value returned depends on the delimiter parameter.

  • If the delimiter is not specified then a string list is returned with the default value of "," is used.
  • If the delimiter json then a json array is returned. (as of MapTool 1.3b49)
  • Otherwise a string list is returned with the delimiter passed in.

Usage

[h: names = getPropertyNames()]
[h: names = getPropertyNames(delim)]

delim is the delimiter used to separate the values in the string list which defaults to "," if not specified.

Example

To display the names of all of the properties on the current token use.
[h: names = getPropertyNames()]
[foreach(name, names, "<br>"): name]

Notes

When token properties are created during campaign, they are persistent in the MapTool campaign, regardless of whether they are editable in the Edit Token window. In other words, even though a property is removed from the campaign properties, it remains available in the MapTool code. getPropertyNames() will return all token properties that exist or have ever existed in the particular campaign, even if users cannot directly edit those properties (i.e., they do not appear in the token's properties when you double click on a token). To get only properties that are currently visible and editable, use getAllPropertyNames().