getTokenStates: Difference between revisions
m (Conversion script moved page GetTokenStates to getTokenStates: Converting page titles to lowercase) |
m (Text replacement - "source>" to "syntaxhighlight>") |
||
Line 12: | Line 12: | ||
getTokenStates(delim, groupName, id) | getTokenStates(delim, groupName, id) | ||
getTokenStates(delim, groupName, id, mapname) | getTokenStates(delim, groupName, id, mapname) | ||
</ | </syntaxhighlight> | ||
'''Parameter''' | '''Parameter''' | ||
{{param|delim|Specifies the delimiter used in the string list that is returned, default is {{code|","}}. If the value is set to {{code|json}}, the function returns a JSON array instead.}} | {{param|delim|Specifies the delimiter used in the string list that is returned, default is {{code|","}}. If the value is set to {{code|json}}, the function returns a JSON array instead.}} | ||
Line 23: | Line 23: | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[h: states = getTokenStates()] | [h: states = getTokenStates()] | ||
</ | </syntaxhighlight> | ||
To get a [[JSON Array]] of the valid [[Token State]]s in the campaign. | To get a [[JSON Array]] of the valid [[Token State]]s in the campaign. | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[h: states = getTokenStates("json")] | [h: states = getTokenStates("json")] | ||
</ | </syntaxhighlight> | ||
To get a [[JSON Array]] of the valid [[Token State]]s in the ''Damage'' group in the campaign in 1.3b55 or later. | To get a [[JSON Array]] of the valid [[Token State]]s in the ''Damage'' group in the campaign in 1.3b55 or later. | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[h: states = getTokenStates("json", "Damage")] | [h: states = getTokenStates("json", "Damage")] | ||
</ | </syntaxhighlight> | ||
To get a [[JSON Array]] of the [[Token State]]s set to {{true}} for the "Dragon" token: | To get a [[JSON Array]] of the [[Token State]]s set to {{true}} for the "Dragon" token: | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[h: states = getTokenStates("json", "*", "Dragon")] | [h: states = getTokenStates("json", "*", "Dragon")] | ||
</ | </syntaxhighlight> | ||
Revision as of 19:58, 14 March 2023
getTokenStates() Function
true
(1
) for the token.Usage
<source lang="mtmacro" line> getTokenStates() getTokenStates(delim) getTokenStates(delim, groupName) getTokenStates(delim, groupName, id) getTokenStates(delim, groupName, id, mapname) </syntaxhighlight> Parameter
delim
- Specifies the delimiter used in the string list that is returned, default is","
. If the value is set tojson
, the function returns a JSON array instead.groupName
- Specifies the name of the group to get the states for. If set to "*", get all states.id
- The id of the token to get the states set totrue
(1
). If the parameter is not used, instead returns all valid states in the campaign settings.Note: This parameter can only be used in a Trusted Macro.
mapname
- The name of the map where the token is. Set to the current map by default.
Example
<source lang="mtmacro" line> [h: states = getTokenStates()] </syntaxhighlight>
To get a JSON Array of the valid Token States in the campaign. <source lang="mtmacro" line> [h: states = getTokenStates("json")] </syntaxhighlight>
To get a JSON Array of the valid Token States in the Damage group in the campaign in 1.3b55 or later. <source lang="mtmacro" line> [h: states = getTokenStates("json", "Damage")] </syntaxhighlight>
To get a JSON Array of the Token States set to true
(1
) for the "Dragon" token:
<source lang="mtmacro" line>
[h: states = getTokenStates("json", "*", "Dragon")]
Version Changes
- 1.3b55 - Added the
groupName
parameter. - 1.5.7 - Added
id
andmapname
parameter options.