getTokenX: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 20: | Line 20: | ||
'''Which coordinate is returned for larger tokens''' | '''Which coordinate is returned for larger tokens''' | ||
With the exception of one case the coordinates of the cell are given where the UPPER LEFT CORNER of the token is in at that moment. The exception to this is when the token is 'Freesize' AND 'Snapped to Grid' AND '''NOT''' 'On Background Layer'. In that particular case the coordinates of the cell where the CENTRE of the image of the token is at. | * With the exception of one case the coordinates of the cell are given where the UPPER LEFT CORNER of the token is in at that moment. | ||
* The exception to this is when the token is 'Freesize' AND 'Snapped to Grid' AND '''NOT''' 'On Background Layer'. In that particular case the coordinates of the cell where the CENTRE of the image of the token is at. | |||
* Note that if you rotate the image such that the image is no longer in the upper left corner, the upper left corner of its '''native position''' is still returned as its coordinate. | |||
|examples= | |examples= |
Revision as of 14:36, 15 August 2011
getTokenX() Function
• Introduced in version 1.3b51
Gets the X coordinate of a token.
Usage
getTokenX()
getTokenX(units)
getTokenX(units, id)
Parameters
units
- If set tofalse
(0
), the coordinate is a location on the grid in cells. Defaults totrue
(1
), where the coordinate is in Distance Per Cell units (in other words 0:distance in cells, 1: distance in pixels)'.id
- The id of the token to move, defaults to the Current Token.
Which coordinate is returned for larger tokens
- With the exception of one case the coordinates of the cell are given where the UPPER LEFT CORNER of the token is in at that moment.
- The exception to this is when the token is 'Freesize' AND 'Snapped to Grid' AND NOT 'On Background Layer'. In that particular case the coordinates of the cell where the CENTRE of the image of the token is at.
- Note that if you rotate the image such that the image is no longer in the upper left corner, the upper left corner of its native position is still returned as its coordinate.
Examples
Moves the Current Token down
5
units, and left 10
units.
[h: CurrentX = getTokenX()]
[h: CurrentY = getTokenY()]
[h: NewX = CurrentX + 5]
[h: NewY = CurrentY - 10]
[h: moveToken(NewX, NewY)]
Moves the Current Token down 5
cells, and left 10
cells.
[h: CurrentX = getTokenX(0)]
[h: CurrentY = getTokenY(0)]
[h: NewX = CurrentX + 5]
[h: NewY = CurrentY - 10]
[h: moveToken(NewX, NewY, 0)]