js:MapTool: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Created page with "Within the javascript environment used by {{code|js.eval}}, {{code|MapTool}} is the main entry point for manipulating tokens or maps, sending chat messages, running macros, an...")
 
No edit summary
Line 52: Line 52:
* {{code|return}} - The token with specified ID.   
* {{code|return}} - The token with specified ID.   
* {{code|throws}} - ArrayIndexOutOfBounds exception if the token cannot be found.
* {{code|throws}} - ArrayIndexOutOfBounds exception if the token cannot be found.
}}
{{MacroFunction
|name=MapTool.tokens.getMapTokens
|trusted=true
|version=1.9.4
|description=
Returns a list of all tokens on all maps.
|usage=
<source lang="javascript" line>
let token = MapTool.tokens.getMapTokens();
</source>
'''Parameters'''
* {{code|return}} - A list containing all tokens on every map. 




Line 65: Line 87:
[[js:MapTool.chat|JS: MapTool.chat]]<br/>
[[js:MapTool.chat|JS: MapTool.chat]]<br/>
[[js:MapTool.clientInfo|JS: MapTool.clientInfo]]<br/>
[[js:MapTool.clientInfo|JS: MapTool.clientInfo]]<br/>
[[js:MapTool.tokens|JS: MapTool.tokens]]<br/>
[[js:Token|JS: Tokens]]<br/>
[[js:MTScript|JS: MTScript]]
[[js:MTScript|JS: MTScript]]
[[Category:Javascript Function]]
[[Category:Javascript Function]]

Revision as of 05:39, 4 August 2021

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, or null 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.


MapTool.tokens.getMapTokens() Function

 Note: This function can only be used in a Trusted Macro

Introduced in version 1.9.4
Returns a list of all tokens on all maps.

Usage

let token = MapTool.tokens.getMapTokens();

Parameters

  • return - A list containing all tokens on every map.


See Also

JS: MapTool.chat
JS: MapTool.clientInfo
JS: Tokens
JS: MTScript