getInitiativeList: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 23: | Line 23: | ||
</source> | </source> | ||
'''Output''' | '''Output''' | ||
A list of the key/value pairs in the object returned. | A list of the key/value pairs in the object returned. | ||
<source lang="mtmacro"> | <source lang="mtmacro"> |
Revision as of 03:04, 30 September 2019
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.