js:MapTool
Within the javascript environment used by js.eval
, MapTool
is the main entry point for manipulating tokens or maps, sending chat messages, running macros, and so on. This page details the attributes and functions available on the MapTool
object.
MapTool.getSelectedTokens() Function
Note: This function can only be used in a Trusted Macro
• Introduced in version 1.9.4
Returns a javascript array containing the selected tokens.
Usage
let a = MapTool.getSelectedTokens();
Parameters
return
- An array containing all selected tokens.
MapTool.getSelected() Function
Note: This function can only be used in a Trusted Macro
• Introduced in version 1.9.4
Like
getSelectedTokens()
, but only returns the first token.Usage
let token = MapTool.getSelected();
Parameters
return
- The first selected token, ornull
if no token is selected.
MapTool.getTokenByID() Function
Note: This function can only be used in a Trusted Macro
• Introduced in version 1.9.4
Returns the token specified.
Usage
let token = MapTool.getTokenByID(tid);
Parameters
tid
- String containing a valid token ID.return
- The token with specified ID.throws
- ArrayIndexOutOfBounds exception if the token cannot be found.
See Also
JS: MapTool.chat
JS: MapTool.clientInfo
JS: MapTool.tokens
JS: MTScript