js:MapTool: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 5: Line 5:
|name=MapTool.getSelectedTokens
|name=MapTool.getSelectedTokens
|trusted=true
|trusted=true
|version=1.9.4
|version=1.10.0
|description=
|description=
Returns a javascript array containing the selected tokens.   
Returns a javascript array containing the selected tokens.   
Line 22: Line 22:
|name=MapTool.getSelected
|name=MapTool.getSelected
|trusted=true
|trusted=true
|version=1.9.4
|version=1.10.0
|description=
|description=
Like {{code|getSelectedTokens()}}, but only returns the first token.
Like {{code|getSelectedTokens()}}, but only returns the first token.
Line 40: Line 40:
|name=MapTool.getTokenByID
|name=MapTool.getTokenByID
|trusted=true
|trusted=true
|version=1.9.4
|version=1.10.0
|description=
|description=
Returns the token specified.
Returns the token specified.
Line 64: Line 64:
|name=MapTool.tokens.getMapTokens
|name=MapTool.tokens.getMapTokens
|trusted=true
|trusted=true
|version=1.9.4
|version=1.10.0
|description=
|description=
Returns a list of all tokens on all maps.
Returns a list of all tokens on all maps.

Revision as of 20:35, 22 September 2021

 This article describes a feature or macro function that is experimental and may be subject to change.

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.10.0
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.10.0
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.10.0
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.10.0
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
js.eval()