getTokenMap: Difference between revisions
Jump to navigation
Jump to search
m (Conversion script moved page GetTokenMap to getTokenMap: Converting page titles to lowercase) |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
getTokenMap( | getTokenMap(tokenRef) | ||
getTokenMap( | getTokenMap(tokenRef, delim) | ||
</ | </syntaxhighlight> | ||
'''Parameters''' | '''Parameters''' | ||
'''Parameters''' | '''Parameters''' | ||
{{param| | {{param|tokenRef|Either the name of the token or the ID.}} | ||
{{param|delim|The delimiter used in the string list returned, defaults to {{code|","}}. If set to {{code|json}}, then a JSON array is returned.}} | {{param|delim|The delimiter used in the string list returned, defaults to {{code|","}}. If set to {{code|json}}, then a JSON array is returned.}} | ||
{{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= | ||
Suppose a token named "Dragon" is on two maps, "Grasslands" and "Arid". The command | Suppose a token named "Dragon" is on two maps, "Grasslands" and "Arid". The command | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: getTokenMap("Dragon", "json")] | [r: getTokenMap("Dragon", "json")] | ||
</ | </syntaxhighlight> | ||
returns the JSON Array: | returns the JSON Array: | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
["Grasslands","Arid"] | ["Grasslands","Arid"] | ||
</ | </syntaxhighlight> | ||
}} | }} | ||
[[Category:Token Function]] | [[Category:Token Function]] | ||
[[Category:Map Function]] | [[Category:Map Function]] |
Latest revision as of 23:59, 14 May 2024
getTokenMap() Function
Note: This function can only be used in a Trusted Macro
• Introduced in version 1.5.11
Gets the list of map(s) where a token resides. The list is returned either as a string list, or as a JSON Array.
Usage
getTokenMap(tokenRef)
getTokenMap(tokenRef, delim)
Parameters Parameters
tokenRef
- Either the name of the token or the ID.delim
- The delimiter used in the string list returned, defaults to","
. If set tojson
, then a JSON array is returned.
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
Suppose a token named "Dragon" is on two maps, "Grasslands" and "Arid". The command
[r: getTokenMap("Dragon", "json")]
returns the JSON Array:
["Grasslands","Arid"]