js:Token: Difference between revisions
No edit summary |
m (Added isOwner(); lots of grammatical and syntax clean up) |
||
Line 7: | Line 7: | ||
|version=1.10.0 | |version=1.10.0 | ||
|description= | |description= | ||
Returns the | Returns the Notes field of the token. No processing of the content is performed (this means Notes entered as HTNL will return the HTML content, for example). | ||
|usage= | |usage= | ||
<syntaxhighlight lang="javascript" line> | <syntaxhighlight lang="javascript" line> | ||
Line 19: | Line 19: | ||
|version=1.10.0 | |version=1.10.0 | ||
|description= | |description= | ||
Sets the | Sets the Notes field of the token. | ||
|usage= | |usage= | ||
<syntaxhighlight lang="javascript" line> | <syntaxhighlight lang="javascript" line> | ||
token.setNotes(newNotes); | token.setNotes(newNotes); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* {{param|newNotes|a string representing the new Notes of the token. See {{func|getNotes}} for details.}} | |||
}} | }} | ||
Line 43: | Line 45: | ||
|version=1.10.0 | |version=1.10.0 | ||
|description= | |description= | ||
Sets the name of the token | Sets the name of the token. | ||
|usage= | |usage= | ||
<syntaxhighlight lang="javascript" line> | <syntaxhighlight lang="javascript" line> | ||
token.setName(newName); | token.setName(newName); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* {{param|newName|a string representing the new name of the token. See {{func|setName}} for details.}} | |||
}} | }} | ||
Line 55: | Line 59: | ||
|version=1.10.0 | |version=1.10.0 | ||
|description= | |description= | ||
Returns true if sight is enabled for the token | Returns {{code|true}} if sight is enabled for the token. | ||
|usage= | |usage= | ||
<syntaxhighlight lang="javascript" line> | <syntaxhighlight lang="javascript" line> | ||
Line 67: | Line 71: | ||
|version=1.10.0 | |version=1.10.0 | ||
|description= | |description= | ||
Returns the | Returns the MapTool token ID of the token. | ||
|usage= | |usage= | ||
<syntaxhighlight lang="javascript" line> | <syntaxhighlight lang="javascript" line> | ||
Line 79: | Line 83: | ||
|version=1.10.0 | |version=1.10.0 | ||
|description= | |description= | ||
Returns the value of the token property. | Returns the value of the given token property. | ||
|usage= | |usage= | ||
<syntaxhighlight lang="javascript" line> | <syntaxhighlight lang="javascript" line> | ||
token.getProperty(property); | token.getProperty(property); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* {{param|property|a string representing the name of the property on the token. See {{func|getProperty}} for details.}} | |||
}} | }} | ||
Line 96: | Line 102: | ||
token.setProperty(property, newValue); | token.setProperty(property, newValue); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* {{param|property|a string representing the name of the property on the token. See {{func|setProperty}} for details.}} | |||
* {{param|newValue|the new value to store into the token property.}} | |||
}} | }} | ||
Line 108: | Line 117: | ||
token.getX(); | token.getX(); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
See {{func|getTokenX}} for details. | |||
}} | }} | ||
{{MacroFunction | {{MacroFunction | ||
Line 121: | Line 131: | ||
token.getY(); | token.getY(); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
See {{func|getTokenY}} for details. | |||
}} | }} | ||
Line 133: | Line 145: | ||
token.setX(newX); | token.setX(newX); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* {{param|newX|a number representing the new X coordinate of the token. See {{func|getTokenX}} and {{func|moveToken}} for details.}} | |||
}} | }} | ||
Line 145: | Line 159: | ||
token.setY(newY); | token.setY(newY); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* {{param|newY|a number representing the new Y coordinate of the token. See {{func|getTokenY}} and {{func|moveToken}} for details.}} | |||
}} | |||
{{MacroFunction | |||
|name=token.isOwner | |||
|trusted=true | |||
|version=1.10.0 | |||
|description= | |||
Returns {{code|true}} if the given player is an owner. | |||
|usage= | |||
<syntaxhighlight lang="javascript" line> | |||
token.isOwner(); | |||
</syntaxhighlight> | |||
Ownership is determine by a strict check of the player names listed as owners (see the '''Ownership''' tab of the ''Token Editor Dialog''). This means that if no player names are selected there but '''ALL''' is selected, the result will still return {{code|false}} if the current player is not in the owner list. The same thing applies to GMs. See {{func|isOwner}} for details. | |||
}} | }} | ||
< | <h2>See Also</h2> | ||
[[js:MapTool|JS: MapTool]]<br/> | [[js:MapTool|JS: MapTool]]<br/> | ||
[[Category:Javascript Function]] | [[Category:Javascript Function]] |
Revision as of 05:31, 11 June 2023
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
, Tokens are represented by the Token
class. The token class cannot be directly instantiated, but tokens can be found from the MapTool
top level name.
token.getNotes() Function
Note: This function can only be used in a Trusted Macro
Usage
token.getNotes();
token.setNotes() Function
Note: This function can only be used in a Trusted Macro
Usage
token.setNotes(newNotes);
newNotes
- a string representing the new Notes of the token. See getNotes() for details.
token.getName() Function
Note: This function can only be used in a Trusted Macro
Usage
token.getName();
token.setName() Function
Note: This function can only be used in a Trusted Macro
Usage
token.setName(newName);
newName
- a string representing the new name of the token. See setName() for details.
token.hasSight() Function
Note: This function can only be used in a Trusted Macro
true
if sight is enabled for the token.Usage
token.hasSight();
token.getId() Function
Note: This function can only be used in a Trusted Macro
Usage
token.getId();
token.getProperty() Function
Note: This function can only be used in a Trusted Macro
Usage
token.getProperty(property);
property
- a string representing the name of the property on the token. See getProperty() for details.
token.setProperty() Function
Note: This function can only be used in a Trusted Macro
Usage
token.setProperty(property, newValue);
property
- a string representing the name of the property on the token. See setProperty() for details.newValue
- the new value to store into the token property.
token.getX() Function
Note: This function can only be used in a Trusted Macro
Usage
token.getX();
See getTokenX() for details.
token.getY() Function
Note: This function can only be used in a Trusted Macro
Usage
token.getY();
See getTokenY() for details.
token.setX() Function
Note: This function can only be used in a Trusted Macro
Usage
token.setX(newX);
newX
- a number representing the new X coordinate of the token. See getTokenX() and moveToken() for details.
token.setY() Function
Note: This function can only be used in a Trusted Macro
Usage
token.setY(newY);
newY
- a number representing the new Y coordinate of the token. See getTokenY() and moveToken() for details.
token.isOwner() Function
Note: This function can only be used in a Trusted Macro
true
if the given player is an owner.Usage
token.isOwner();
Ownership is determine by a strict check of the player names listed as owners (see the Ownership tab of the Token Editor Dialog). This means that if no player names are selected there but ALL is selected, the result will still return false
if the current player is not in the owner list. The same thing applies to GMs. See isOwner() for details.