getLibPropertyNames: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(8 intermediate revisions by 3 users not shown) | |||
Line 5: | Line 5: | ||
Returns a [[String List]] or [[JSON Array]] containing the names of the [[Token Property|Token Properties]] on a [[Library 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 [[Library Token]]. The type of the value returned depends on the delimiter parameter. | ||
{{note| | {{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 to macros. '''getLibPropertyNames''' 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}}.}} | ||
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 to macros. '''getLibPropertyNames''' 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= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
getLibPropertyNames() | getLibPropertyNames() | ||
getLibPropertyNames(delim) | getLibPropertyNames(delim) | ||
getLibPropertyNames(id, delim) | getLibPropertyNames(id, delim) | ||
</ | </syntaxhighlight > | ||
'''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"}}. }} | ||
Line 24: | Line 17: | ||
|example= | |example= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: names = getLibPropertyNames()] | [h: names = getLibPropertyNames()] | ||
[foreach(name, names, "<br>"): name] | [foreach(name, names, "<br>"): name] | ||
</ | </syntaxhighlight > | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: names = getLibPropertyNames("Lib:some_lib_token")] | [h: names = getLibPropertyNames("Lib:some_lib_token")] | ||
[foreach(name, names, "<br>"): name] | [foreach(name, names, "<br>"): name] | ||
</ | </syntaxhighlight > | ||
|changes= | |changes= | ||
'''Updated in 1.11:''' | |||
MTscript functions for acting on library tokens have been modified to also work on [[MTscript_functions_related_to_Add-on_libraries|Add-on libraries]]. | |||
This modification allows the namespace of the add-on library to be used where the {{code|Lib:}} token name would normally appear. For example, | |||
<syntaxhighlight lang="mtmacro" line> | |||
[h: getLibPropertyNames("com.myname.mt.my-first-addon")] | |||
</syntaxhighlight > | |||
}} | }} | ||
[[Category:Token Function]][[Category:Token Library Function]][[Category:Property Function]] | [[Category:Token Function]] | ||
[[Category:Token Library Function]] | |||
[[Category:Property Function]] | |||
[[Category:Add-on Library Functions]] |
Latest revision as of 23:59, 23 February 2024
getLibPropertyNames() Function
• Introduced in version 1.5.0
Returns a String List or JSON Array containing the names of the Token Properties on a Library 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 to macros. getLibPropertyNames 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
getLibPropertyNames()
getLibPropertyNames(delim)
getLibPropertyNames(id, delim)
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 tokenid
of the token which has its property names returned, defaults to the Current Token. This parameter may be*
orthis
to indicate the current Lib token that this macro is executing on.Note: This parameter can only be used in a Trusted Macro.
Example
[h: names = getLibPropertyNames()]
[foreach(name, names, "<br>"): name]
[h: names = getLibPropertyNames("Lib:some_lib_token")]
[foreach(name, names, "<br>"): name]
Version Changes
Updated in 1.11:
MTscript functions for acting on library tokens have been modified to also work on Add-on libraries.
This modification allows the namespace of the add-on library to be used where the Lib:
token name would normally appear. For example,
[h: getLibPropertyNames("com.myname.mt.my-first-addon")]