getTokenRotation: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
{{stub|No examples yet.}}
{{MacroFunction
{{MacroFunction
|name= getTokenRotation
|name= getTokenRotation
Line 6: Line 5:
|version=1.5.0
|version=1.5.0
|description=
|description=
Retrieves the token's rotation angle in degrees.
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 +85.
 
For Top Down tokens, this is the rotation of the token image itself from the default of 0 degrees.


|usage=
|usage=
Line 19: Line 22:
The function returns the token's rotation as a numeric value measured in degrees.
The function returns the token's rotation as a numeric value measured in degrees.
|example=
|example=
Needs real example showing possible return values.  I recall there was some discussion about whether the return value went from -90 to +270 or from 0 to 360.  It calls '''Token.getFacingInDegrees()'''.
Get the rotation for the four tokens shown below.
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[r: getTokenRotation()]
[h: switchToken("Mage")]
</source>
[r: token.name] - [r: r = getTokenRotation()]<br>
[h: switchToken("Elf")]
[r: token.name] - [r: r = getTokenRotation()]<br>
[h: switchToken("Hero")]
[r: token.name] - [r: r = getTokenRotation()]<br>
[h: switchToken("Troll")]
[r: token.name] - [r: r = getTokenRotation()]</source>
Returns:
Returns:
 
[[File:getTokenRotation.png]]
|also=
|also=
[[getTokenFacing]]
}}
}}
[[Category:Token Function]]
[[Category:Token Function]]

Revision as of 18:39, 1 June 2019

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 +85.

For Top Down tokens, this is the rotation of the token image itself from the default of 0 degrees.

Usage

getTokenRotation()
getTokenRotation(id)

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

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

Example

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

Returns:

File:getTokenRotation.png

See Also