getInitiativeList: Difference between revisions
Jump to navigation
Jump to search
m (Conversion script moved page GetInitiativeList to getInitiativeList: Converting page titles to lowercase) |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 8: | Line 8: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[ json = getInitiativeList() ] | [ json = getInitiativeList() ] | ||
</ | </syntaxhighlight> | ||
'''Parameters''' | '''Parameters''' | ||
None. | None. | ||
Line 16: | Line 16: | ||
|example= | |example= | ||
The following code will simply return a JSON object and print each property name one at a time on separate lines. Refer to [[JSON Object]] for more information about JSON object themselves and [[json.get]] for information on retrieving properties and their values. | The following code will simply return a JSON object and print each property name one at a time on separate lines. Refer to [[JSON Object]] for more information about JSON object themselves and [[json.get]] for information on retrieving properties and their values. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: json = getInitiativeList() ] | [h: json = getInitiativeList() ] | ||
[r, foreach(item, json, "<br>"), code: { | [r, foreach(item, json, "<br>"), code: { | ||
[r: item]: [r:json.get(json,item)] | [r: item]: [r:json.get(json,item)] | ||
}] | }] | ||
</ | </syntaxhighlight> | ||
'''Output''' | '''Output''' | ||
A list of the key/value pairs in the object returned. | A list of the key/value pairs in the object returned. | ||
< | <syntaxhighlight lang="mtmacro"> | ||
round: Round Number | round: Round Number | ||
map: Map Name | map: Map Name | ||
current: Current Position in List | current: Current Position in List | ||
tokens: An Array of Objects for Each Token in List | tokens: An Array of Objects for Each Token in List | ||
</ | </syntaxhighlight> | ||
This example prints a nicely formatted output showing what the contents of the JSON object look like. | This example prints a nicely formatted output showing what the contents of the JSON object look like. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: json = getInitiativeList() ] | [h: json = getInitiativeList() ] | ||
<pre>[r: json.indent(json) ]</pre> | <pre>[r: json.indent(json) ]</pre> | ||
</ | </syntaxhighlight> | ||
'''Output''' | '''Output''' | ||
< | <syntaxhighlight lang="javascript"> | ||
{ | { | ||
"round": 1, | "round": 1, | ||
Line 76: | Line 76: | ||
] | ] | ||
} | } | ||
</ | </syntaxhighlight> | ||
|changes= | |changes= |
Latest revision as of 23:59, 14 March 2023
getInitiativeList() Function
• Introduced in version 1.3b57
Retrieves a list of all tokens currently in the Initiative Panel. The return value is a JSON object with various information about initiative, including global information (round number, which map is current, which token is current) and token-specific information (token id, initiative value, whether the token is holding or not).
When called from a Trusted Macro or by a client with GM authority, it will return all information. Otherwise it only returns information visible to the current player. In other words, it respects the Initiative Panel's
Hide NPCs
and the token's Visible To Owner Only
flags, among others. (This is new in 1.3b78. Prior versions didn't have the check for trusted context at all.)Usage
[ json = getInitiativeList() ]
Parameters None.
Example
The following code will simply return a JSON object and print each property name one at a time on separate lines. Refer to JSON Object for more information about JSON object themselves and json.get for information on retrieving properties and their values.
[h: json = getInitiativeList() ]
[r, foreach(item, json, "<br>"), code: {
[r: item]: [r:json.get(json,item)]
}]
Output
A list of the key/value pairs in the object returned.
round: Round Number
map: Map Name
current: Current Position in List
tokens: An Array of Objects for Each Token in List
This example prints a nicely formatted output showing what the contents of the JSON object look like.
[h: json = getInitiativeList() ]
<pre>[r: json.indent(json) ]</pre>
Output
{
"round": 1,
"map": "Grasslands",
"current": 1,
"tokens": [
{
"holding": false,
"initiative": "20",
"tokenId": "3C2518218E5E4D088F96FAE93A048357"
},
{
"holding": false,
"initiative": "17",
"tokenId": "8FA88395DA264D04B1B6F0F0E38A7692"
},
{
"holding": false,
"initiative": "13",
"tokenId": "066CDB7953B74F239952AD82D4147433"
},
{
"holding": false,
"initiative": "10",
"tokenId": "AF6D8BEB95C6424287E09206AD155120"
},
{
"holding": false,
"initiative": "3",
"tokenId": "27B65E37216F4A02BCE59899CE2048AA"
},
{
"holding": false,
"initiative": "1",
"tokenId": "4F06F4B20A954D719B9788F07EB923BE"
}
]
}
Version Changes
- 1.3b57 - Added macro function.
- 1.3b78 - Filters output based on trusted status.