js:MapTool: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
{{Experimental}}
{{Experimental}}
Within the javascript environment used by {{func|js.eval}}, {{code|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 {{code|MapTool}} object.
Within the javascript environment used by {{func|js.eval}}, {{code|MapTool}} is the main entry point for manipulating tokens or maps, sending chat messages, running macros, and so on.  This page details the attributes available on the {{code|MapTool}} object.


{{MacroFunction
|name=MapTool.getSelectedTokens
|trusted=true
|version=1.10.0
|description=
Returns a javascript array containing the selected tokens. 


|usage=
<source lang="javascript" line>
let a = MapTool.getSelectedTokens();
</source>
'''Parameters'''
* {{code|return}} - An array containing all selected tokens.
}}
{{MacroFunction
|name=MapTool.getSelected
|trusted=true
|version=1.10.0
|description=
Like {{code|getSelectedTokens()}}, but only returns the first token.
|usage=
<source lang="javascript" line>
let token = MapTool.getSelected();
</source>
'''Parameters'''
* {{code|return}} - The first selected token, or {{code|null}} if no token is selected.
}}
{{MacroFunction
|name=MapTool.getTokenByID
|trusted=true
|version=1.10.0
|description=
Returns the token specified.
|usage=
<source lang="javascript" line>
let token = MapTool.getTokenByID(tid);
</source>
'''Parameters'''
* {{code|tid}} - String containing a valid token ID.
* {{code|return}} - The token with specified ID. 
* {{code|throws}} - ArrayIndexOutOfBounds exception if the token cannot be found.
}}
{{MacroFunction
|name=MapTool.tokens.getMapTokens
|trusted=true
|version=1.10.0
|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 88: Line 9:
[[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:Token|JS: Tokens]]<br/>
[[js:MTScript|JS: MTScript]]<br/>
[[js:MTScript|JS: MTScript]]<br/>
{{func|js.eval}}
{{func|js.eval}}
[[Category:Javascript Function]]
[[Category:Javascript Function]]

Revision as of 19:15, 7 October 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 available on the MapTool object.



See Also

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

js.eval()