From RPTools Wiki
Jump to navigationJump to search

getTokenRotation() Function

Introduced in version 1.5.0
Retrieves the angle of rotation for the token from the default position. Returned value is in degrees.

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.


getTokenRotation(id, mapname)


  • 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.

The function returns the token's rotation as a numeric value measured in degrees.


Get the rotation for the four tokens shown below.
[h: switchToken("Mage")]
[r:] - [r: r = getTokenRotation()]<br>
[h: switchToken("Elf")]
[r:] - [r: r = getTokenRotation()]<br>
[h: switchToken("Hero")]
[r:] - [r: r = getTokenRotation()]<br>
[h: switchToken("Troll")]
[r:] - [r: r = getTokenRotation()]

Returns: getTokenRotation.png

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:

facing = -(rotation + 90)
rotation = -(facing + 90)

See Also

Version Changes

  • 1.5.4 - Added mapname parameter option.