js:Token: Difference between revisions
Cold Ankles (talk | contribs) (Added new 1.14 and 1.15 Token Functions) |
m (Changed HTNL to HTML) |
||
(One intermediate revision by the same user not shown) | |||
Line 7: | Line 7: | ||
|version=1.10.0 | |version=1.10.0 | ||
|description= | |description= | ||
Returns the Notes field of the token. No processing of the content is performed (this means Notes entered as | Returns the Notes field of the token. No processing of the content is performed (this means Notes entered as HTML will return the HTML content, for example). | ||
|usage= | |usage= | ||
<syntaxhighlight lang="javascript" line> | <syntaxhighlight lang="javascript" line> |
Latest revision as of 23:59, 10 February 2024
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
, ie. the one that executes within GraalVM and NOT the one used by dialog5() or frame5(), 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(playerName);
playerName
- a string representing the player name to check for. See isOwner() for details, but note that this function requires a single parameter and the MTscript one does not.
Ownership is determined thusly:
- This call is running in a trusted context — returns
true
. - This token has ALL players as owners — returns
true
. - This token has the given player name in the list of owners — returns
true
. - All other conditions return
false
.
token.isOnCurrentMap() Function
Usage
token.isOnCurrentMap();
token.getMapName() Function
Usage
token.getMapName();
token.getState() Function
Usage
token.getState(stateName);
stateName
- The name of the state to check for. See getState() for MTScript equivalent.
token.setState() Function
Note: This function can only be used in a Trusted Macro
Usage
token.setState(stateName, aValue);
stateName
- The name of the state to set. See setState() for MTScript equivalent.aValue
- boolean state to set.
token.setAllStates() Function
Note: This function can only be used in a Trusted Macro
Usage
token.setAllStates(aValue);
aValue
- boolean state to set. See setAllStates() for MTScript equivalent.
token.getActiveStates() Function
Usage
token.getActiveStates();
token.isPC() Function
Usage
token.isPC();
token.setPC() Function
Note: This function can only be used in a Trusted Macro
Usage
token.setPC();
token.isNPC() Function
Usage
token.isNPC();
token.setNPC() Function
Note: This function can only be used in a Trusted Macro
Usage
token.setNPC();
token.getType() Function
Usage
token.getType();