getPropertyNames: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Oops, swapped id/delim but that only applies to getLibPropertyNames, not this function)
mNo edit summary
Line 4: Line 4:
|description=
|description=
Returns a [[String List]] or [[JSON Array]] containing the names of the [[Token Property|Token Properties]] on a [[Token]]. The type of the value returned depends on the delimiter parameter.  
Returns a [[String List]] or [[JSON Array]] containing the names of the [[Token Property|Token Properties]] on a [[Token]]. The type of the value returned depends on the delimiter parameter.  
{{note|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 {{func|getAllPropertyNames}}.}}


|usage=
|usage=
Line 17: Line 19:
'''Parameters'''
'''Parameters'''
{{param|delim|The delimiter used to separate the values in the [[String List]], defaults to {{code|","}}. Returns a [[JSON Array]] if set to {{code|"json"}}. }}
{{param|delim|The delimiter used to separate the values in the [[String List]], defaults to {{code|","}}. Returns a [[JSON Array]] if set to {{code|"json"}}. }}
{{param|id|The token {{code|id}} of the token which has its property names returned, defaults to the [[Current Token]].  This parameter may be {{code|*}} or {{code|this}} to indicate the current Lib token that this macro is executing on. {{TrustedParameter}} }}
{{param|id|The token {{code|id}} of the token which has its property names returned, defaults to the [[Current Token]]. {{TrustedParameter}} }}


|example=
|example=
Line 25: Line 27:
[foreach(name, names, "<br>"): name]
[foreach(name, names, "<br>"): name]
</source>
</source>
|changes=
|changes=
{{change|1.3b49|Added {{code|json}} delimiter option.}}
{{change|1.3b49|Added {{code|json}} delimiter option.}}
{{change|1.3b51|Added {{code|id}} parameter option.}}
{{change|1.3b51|Added {{code|id}} parameter option.}}
}}
}}
===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()]].
[[Category:Token Function]][[Category:Property Function]]
[[Category:Token Function]][[Category:Property Function]]

Revision as of 22:27, 16 February 2019

getPropertyNames() Function

Introduced in version 1.3b48
Returns a String List or JSON Array containing the names of the Token Properties on a Token. The type of the value returned depends on the delimiter parameter.


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().

Usage

getPropertyNames()
getPropertyNames(delim)
getPropertyNames(delim, id)

Parameters

  • delim - The delimiter used to separate the values in the String List, defaults to ",". Returns a JSON Array if set to "json".
  • id - The token id of the token which has its property names returned, defaults to the Current Token.

     Note: This parameter can only be used in a Trusted Macro

Example

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


Version Changes

  • 1.3b49 - Added json delimiter option.
  • 1.3b51 - Added id parameter option.