js:Token: Difference between revisions
m (Changed HTNL to HTML) |
|||
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{Experimental}} | {{Experimental}} | ||
Within the | Within the JavaScript environment used by {{code|js.eval}}, ie. the one that executes within GraalVM and NOT the one used by {{func|dialog5}} or {{func|frame5}}, tokens are represented by the {{code|Token}} class. The {{code|Token}} class cannot be directly instantiated, but tokens can be found from the {{code|MapTool}} top level name. | ||
{{MacroFunction | {{MacroFunction | ||
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 HTML will return the HTML content, for example). | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="javascript" line> | ||
token.getNotes(); | token.getNotes(); | ||
</ | </syntaxhighlight> | ||
}} | }} | ||
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> | ||
token.setNotes(newNotes); | token.setNotes(newNotes); | ||
</ | </syntaxhighlight> | ||
* {{param|newNotes|a string representing the new Notes of the token. See {{func|getNotes}} for details.}} | |||
}} | }} | ||
Line 33: | Line 35: | ||
Returns the name of the token. | Returns the name of the token. | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="javascript" line> | ||
token.getName(); | token.getName(); | ||
</ | </syntaxhighlight> | ||
}} | }} | ||
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> | ||
token.setName(newName); | token.setName(newName); | ||
</ | </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> | ||
token.hasSight(); | token.hasSight(); | ||
</ | </syntaxhighlight> | ||
}} | }} | ||
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> | ||
token.getId(); | token.getId(); | ||
</ | </syntaxhighlight> | ||
}} | }} | ||
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> | ||
token.getProperty(property); | token.getProperty(property); | ||
</ | </syntaxhighlight> | ||
* {{param|property|a string representing the name of the property on the token. See {{func|getProperty}} for details.}} | |||
}} | }} | ||
Line 93: | Line 99: | ||
Sets the value of the token property. | Sets the value of the token property. | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="javascript" line> | ||
token.setProperty(property, newValue); | token.setProperty(property, newValue); | ||
</ | </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 105: | Line 114: | ||
Returns the X position of the token. | Returns the X position of the token. | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="javascript" line> | ||
token.getX(); | token.getX(); | ||
</ | </syntaxhighlight> | ||
See {{func|getTokenX}} for details. | |||
}} | }} | ||
{{MacroFunction | {{MacroFunction | ||
Line 118: | Line 128: | ||
Returns the Y position of the token. | Returns the Y position of the token. | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="javascript" line> | ||
token.getY(); | token.getY(); | ||
</ | </syntaxhighlight> | ||
See {{func|getTokenY}} for details. | |||
}} | }} | ||
Line 130: | Line 142: | ||
Sets the X position of the token. | Sets the X position of the token. | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="javascript" line> | ||
token.setX(newX); | token.setX(newX); | ||
</ | </syntaxhighlight> | ||
* {{param|newX|a number representing the new X coordinate of the token. See {{func|getTokenX}} and {{func|moveToken}} for details.}} | |||
}} | }} | ||
Line 142: | Line 156: | ||
Sets the Y position of the token. | Sets the Y position of the token. | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="javascript" line> | ||
token.setY(newY); | token.setY(newY); | ||
</ | </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(playerName); | |||
</syntaxhighlight> | |||
* {{param|playerName|a string representing the player name to check for. See {{func|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 {{code|true}}. | |||
* This token has '''ALL''' players as owners — returns {{code|true}}. | |||
* This token has the given player name in the list of owners — returns {{code|true}}. | |||
* All other conditions return {{code|false}}. | |||
}} | |||
{{MacroFunction | |||
|name=token.isOnCurrentMap | |||
|trusted=false | |||
|version=1.14.0 | |||
|description= | |||
Checks whether the specified token is on the current map. | |||
|usage= | |||
<syntaxhighlight lang="javascript" line> | |||
token.isOnCurrentMap(); | |||
</syntaxhighlight> | |||
}} | |||
{{MacroFunction | |||
|name=token.getMapName | |||
|trusted=false | |||
|version=1.14.0 | |||
|description= | |||
Returns the name of the map the token resides on. | |||
|usage= | |||
<syntaxhighlight lang="javascript" line> | |||
token.getMapName(); | |||
</syntaxhighlight> | |||
}} | |||
{{MacroFunction | |||
|name=token.getState | |||
|trusted=false | |||
|version=1.15.0 | |||
|description= | |||
Checks whether the specified State is active on a token, returning true or false. | |||
|usage= | |||
<syntaxhighlight lang="javascript" line> | |||
token.getState(stateName); | |||
</syntaxhighlight> | |||
* {{param|stateName|The name of the state to check for. See {{func|getState}} for MTScript equivalent.}} | |||
}} | |||
{{MacroFunction | |||
|name=token.setState | |||
|trusted=true | |||
|version=1.15.0 | |||
|description= | |||
Sets the value of the State on Token. If The value is false then the State is unset if it is true then it is set. | |||
|usage= | |||
<syntaxhighlight lang="javascript" line> | |||
token.setState(stateName, aValue); | |||
</syntaxhighlight> | |||
* {{param|stateName|The name of the state to set. See {{func|setState}} for MTScript equivalent.}} | |||
* {{param|aValue|boolean state to set.}} | |||
}} | |||
{{MacroFunction | |||
|name=token.setAllStates | |||
|trusted=true | |||
|version=1.15.0 | |||
|description= | |||
Sets the value of all States on Token. If The value is false then all States are unset if it is true then they are set. | |||
|usage= | |||
<syntaxhighlight lang="javascript" line> | |||
token.setAllStates(aValue); | |||
</syntaxhighlight> | |||
* {{param|aValue|boolean state to set. See {{func|setAllStates}} for MTScript equivalent.}} | |||
}} | |||
{{MacroFunction | |||
|name=token.getActiveStates | |||
|trusted=false | |||
|version=1.15.0 | |||
|description= | |||
Returns a list of states for the token that are currently set(true). | |||
|usage= | |||
<syntaxhighlight lang="javascript" line> | |||
token.getActiveStates(); | |||
</syntaxhighlight> | |||
}} | |||
{{MacroFunction | |||
|name=token.isPC | |||
|trusted=false | |||
|version=1.15.0 | |||
|description= | |||
Checks whether the token is a PC token. | |||
|usage= | |||
<syntaxhighlight lang="javascript" line> | |||
token.isPC(); | |||
</syntaxhighlight> | |||
}} | |||
{{MacroFunction | |||
|name=token.setPC | |||
|trusted=true | |||
|version=1.15.0 | |||
|description= | |||
Sets the token to be a PC Token. | |||
|usage= | |||
<syntaxhighlight lang="javascript" line> | |||
token.setPC(); | |||
</syntaxhighlight> | |||
}} | |||
{{MacroFunction | |||
|name=token.isNPC | |||
|trusted=false | |||
|version=1.15.0 | |||
|description= | |||
Checks whether the token is an NPC token. | |||
|usage= | |||
<syntaxhighlight lang="javascript" line> | |||
token.isNPC(); | |||
</syntaxhighlight> | |||
}} | |||
{{MacroFunction | |||
|name=token.setNPC | |||
|trusted=true | |||
|version=1.15.0 | |||
|description= | |||
Sets the token to be an NPC Token. | |||
|usage= | |||
<syntaxhighlight lang="javascript" line> | |||
token.setNPC(); | |||
</syntaxhighlight> | |||
}} | |||
{{MacroFunction | |||
|name=token.getType | |||
|trusted=false | |||
|version=1.15.0 | |||
|description= | |||
Returns "PC" if token is a PC, and "NPC" if an NPC. | |||
|usage= | |||
<syntaxhighlight lang="javascript" line> | |||
token.getType(); | |||
</syntaxhighlight> | |||
}} | }} | ||
< | <h2>See Also</h2> | ||
[[js:MapTool|JS: MapTool]]<br/> | [[js:MapTool|JS: MapTool]]<br/> | ||
[[Category:Javascript Function]] | [[Category:Javascript Function]] |
Latest revision as of 02:54, 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();