getTokenRotation: Difference between revisions
No edit summary |
m (Text replacement - "source>" to "syntaxhighlight>") |
||
Line 16: | Line 16: | ||
getTokenRotation(id) | getTokenRotation(id) | ||
getTokenRotation(id, mapname) | getTokenRotation(id, mapname) | ||
</ | </syntaxhighlight> | ||
'''Parameters''' | '''Parameters''' | ||
Line 34: | Line 34: | ||
[r: token.name] - [r: r = getTokenRotation()]<br> | [r: token.name] - [r: r = getTokenRotation()]<br> | ||
[h: switchToken("Troll")] | [h: switchToken("Troll")] | ||
[r: token.name] - [r: r = getTokenRotation()]</ | [r: token.name] - [r: r = getTokenRotation()]</syntaxhighlight> | ||
Returns: | Returns: | ||
[[File:GetTokenRotation.png]] | [[File:GetTokenRotation.png]] | ||
Line 46: | Line 46: | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
facing = -(rotation + 90) | facing = -(rotation + 90) | ||
</ | </syntaxhighlight> | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
rotation = -(facing + 90) | rotation = -(facing + 90) | ||
</ | </syntaxhighlight> | ||
|also= | |also= |
Revision as of 19:47, 14 March 2023
getTokenRotation() Function
For Square, Round or Figure token types, this is the change in the facing indicator from the default of 0 degrees or no change in facing. Positive is CW and negative is CCW. Values will range from -270 to +89.
For Top Down tokens, this is the rotation of the token image itself from the default of 0 degrees.Usage
<source lang="mtmacro" line> getTokenRotation() getTokenRotation(id) getTokenRotation(id, mapname) </syntaxhighlight>
Parameters
id
- The token id of the token to retrieve the rotation angle. Defaults to the Current Token.Note: This parameter can only be used in a Trusted Macro.
mapname
- The name of the map to find the token. Defaults to the current map.
Result
The function returns the token's rotation as a numeric value measured in degrees.
Example
<source lang="mtmacro" line>
[h: switchToken("Mage")]
[r: token.name] - [r: r = getTokenRotation()]
[h: switchToken("Elf")]
[r: token.name] - [r: r = getTokenRotation()]
[h: switchToken("Hero")]
[r: token.name] - [r: r = getTokenRotation()]
[h: switchToken("Troll")]
[r: token.name] - [r: r = getTokenRotation()]</syntaxhighlight>
Returns:
Relation to Token Facing
When no facing has been set, getTokenFacing will return the blank string ""
but getTokenRotation will return 0. Consequently getTokenRotation does not require a check to ensure the result is usable for calculations.
To convert from rotation to facing (or vice versa) these relations can be used:
<source lang="mtmacro" line> facing = -(rotation + 90) </syntaxhighlight> <source lang="mtmacro" line> rotation = -(facing + 90)
</syntaxhighlight>See Also
Version Changes
- 1.5.4 - Added
mapname
parameter option.