getAllPropertyNames: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
mNo edit summary
m (Text replacement - "source>" to "syntaxhighlight>")
 
(6 intermediate revisions by 4 users not shown)
Line 2: Line 2:
|name=getAllPropertyNames
|name=getAllPropertyNames
|version=1.3b48
|version=1.3b48
|description=Gets a list containing the [[Token:token property|token property]] names that are defined in the [[Campaign:campaign properties|campaign properties]]. The type of the value returned depends on the delimiter parameter.  
|description=Gets a list containing the [[Token:token property|token property]] names that are defined in the [[Introduction_to_Properties|Campaign Properties]]. The type of the list returned depends on the delimiter parameter.  
* If the delimiter is not specified then a [[Macros:string list|string list]] is returned and the default value of {{code|","}} is used.
* If the delimiter is not specified then a [[Macros:string list|string list]] is returned and the default value of {{code|","}} is used.
* If the delimiter is {{code|"json"}} then a [[JSON Array]] is returned.
* If the delimiter is {{code|"json"}} then a [[JSON Array]] is returned.
* Otherwise a [[Macros:string list|string list]] is returned with the delimiter passed in.
* Otherwise, a [[Macros:string list|string list]] is returned using the delimiter passed in.
 
|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro">
getAllPropertyNames()
getAllPropertyNames()
</source>
<source lang="mtmacro" line>
getAllPropertyNames(type)
getAllPropertyNames(type)
</source>
<source lang="mtmacro" line>
getAllPropertyNames(type, delim)
getAllPropertyNames(type, delim)
</source>
</syntaxhighlight>
'''Parameters'''
{{param|type|The name of the property set to be retrieved. Defaults to all defined token property sets. Use {{code|"*"}} or {{code|""}} when using a delimiter to get all sets. }}
{{param|delim|The delimiter to be used in the list of names returned. Default is {{code|,}} }}


If type is specified then the [[Macros:string list|string list]] contains the [[Token:token property|property]] names for that [[Token:token property type|token property type]], otherwise it will contain the [[Token:token property|token property]] names for all [[Token:token property type|token property type]]s. If delim is specified then it is used to separate the values in the [[Macros:string list|string list]], if it is not specified then it defaults to ','.
If type is specified then the [[Macros:string list|string list]] contains the [[Token:token property|property]] names for that [[Token:token property type|token property type]], otherwise it will contain the [[Token:token property|token property]] names for all [[Token:token property type|token property type]]s. If delim is specified then it is used to separate the values in the [[Macros:string list|string list]], if it is not specified then it defaults to ','.


|examples=
|examples=
You can use the following code to print out all of the properties in the [[Campaign:campaign properties|campaign properties]] list..
You can use the following code to print out all of the properties in the [[Introduction_to_Properties|campaign properties]] list..
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
Campaign Properties<br>
Campaign Properties<br>
[h: props = getAllPropertyNames()]
[h: props = getAllPropertyNames()]
[foreach(name, props, "<br>"): name]
[foreach(name, props, "<br>"): name]
</source>
</syntaxhighlight>


If you have two token property sets, for instance "PC" and "NPC", you could print out all of the properties for the "PC" property set like so:
If you have two token property sets, for instance "PC" and "NPC", you could print out all of the properties for the "PC" property set like so:
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
PC Properties<br>
PC Properties<br>
[h: props=getAllPropertyNames("PC")]
[h: props=getAllPropertyNames("PC")]
[foreach(name, props, "<br>"): name]
[foreach(name, props, "<br>"): name]
</source>
</syntaxhighlight>
 
Get the Basic properties in a [[JSON Array]]:
<syntaxhighlight lang="mtmacro" line>
[r: props=getAllPropertyNames("Basic","json")]
</syntaxhighlight>


|changes=
|changes=

Latest revision as of 23:59, 14 March 2023

getAllPropertyNames() Function

Introduced in version 1.3b48
Gets a list containing the token property names that are defined in the Campaign Properties. The type of the list returned depends on the delimiter parameter.
  • If the delimiter is not specified then a string list is returned and the default value of "," is used.
  • If the delimiter is "json" then a JSON Array is returned.
  • Otherwise, a string list is returned using the delimiter passed in.
 

Usage

getAllPropertyNames()
getAllPropertyNames(type)
getAllPropertyNames(type, delim)

Parameters

  • type - The name of the property set to be retrieved. Defaults to all defined token property sets. Use "*" or "" when using a delimiter to get all sets.
  • delim - The delimiter to be used in the list of names returned. Default is ,

If type is specified then the string list contains the property names for that token property type, otherwise it will contain the token property names for all token property types. If delim is specified then it is used to separate the values in the string list, if it is not specified then it defaults to ','.

Examples

You can use the following code to print out all of the properties in the campaign properties list..
Campaign Properties<br>
[h: props = getAllPropertyNames()]
[foreach(name, props, "<br>"): name]

If you have two token property sets, for instance "PC" and "NPC", you could print out all of the properties for the "PC" property set like so:

PC Properties<br>
[h: props=getAllPropertyNames("PC")]
[foreach(name, props, "<br>"): name]

Get the Basic properties in a JSON Array:

[r: props=getAllPropertyNames("Basic","json")]

Version Changes

  • 1.3b49 - Added json delimiter option.