getPropertyNamesRaw: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{stub|Everything !}}{{MacroFunction |name=getPropertyNamesRaw |version=1.3b64
{{MacroFunction |name=getPropertyNamesRaw |version=1.3b64
|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. The difference between this function and [[getAllPropertyNames|getAllPropertyNames()]] is not clear to me. The only noticeable difference is that [[getAllPropertyNames|getAllPropertyNames()]] returns all the property names in lower case.  
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.
 
The difference between this function and [[getPropertyNames|getPropertyNames()]] is that [[getPropertyNames|getPropertyNames()]] returns all the property names in lower case (see [http://forums.rptools.net/viewtopic.php?f=1&t=12563&p=148937&hilit=getPropertyNamesRaw#p148937 this forum thread] to get the reason why it was created).  


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
getPropertyNamesRaw()
getPropertyNamesRaw()
</source>
<source lang="mtmacro" line>
getPropertyNamesRaw(delim)
getPropertyNamesRaw(delim)
</source>
getPropertyNamesRaw(delim, tokenRef)
<source lang="mtmacro" line>
getPropertyNamesRaw(delim, tokenRef, mapRef)
getPropertyNamesRas(delim, id)
</syntaxhighlight>
</source>
'''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]]. {{TrustedParameter}} }}
{{param|tokenRef|Either the token [[getSelected|{{code|id}}]] or [[getTokenName|Token Name]] of the token which has its property names returned, defaults to the [[Current Token]]. {{TrustedParameter}} }}
{{param|mapRef|The Name or ID of the map to find the token.  Defaults to the current map.}}
{{Note|Token IDs are unique, but Token Names can be duplicated. Using Token Name when more than one token has the same name can produce unexpected results.}}


|example=
|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>
<syntaxhighlight lang="mtmacro" line>
[h: names = getPropertyNamesRaw()]
[h: names = getPropertyNamesRaw()]
[foreach(name, names, "<br>"): name]
[foreach(name, names, "<br>"): name]
</source>
</syntaxhighlight>


|changes=None.}}
|changes=
{{change|1.5.4|Added {{code|mapname}} parameter option.}}
}}
===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. ''getPropertyNamesRaw()'' 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. [[getPropertyNamesRaw|getPropertyNamesRaw()]] 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:Token Function]][[Category:Property Function]]

Latest revision as of 23:59, 13 May 2024

getPropertyNamesRaw() Function

Introduced in version 1.3b64
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. The difference between this function and getPropertyNames() is that getPropertyNames() returns all the property names in lower case (see this forum thread to get the reason why it was created).

Usage

getPropertyNamesRaw()
getPropertyNamesRaw(delim)
getPropertyNamesRaw(delim, tokenRef)
getPropertyNamesRaw(delim, tokenRef, mapRef)

Parameters

  • delim - The delimiter used to separate the values in the String List, defaults to ",". Returns a JSON Array if set to "json".
  • tokenRef - Either the token id or Token Name 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

  • mapRef - The Name or ID of the map to find the token. Defaults to the current map.
Token IDs are unique, but Token Names can be duplicated. Using Token Name when more than one token has the same name can produce unexpected results.

Example

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


Version Changes

  • 1.5.4 - Added mapname 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. getPropertyNamesRaw() 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().