moveToken
(Redirected from MoveToken)
moveToken() Function
• Introduced in version 1.3b51
Move a token to a new location.
Usage
moveToken(x, y)
moveToken(x, y, units)
moveToken(x, y, units, tokenRef)
Parameters
x
- The X coordinate to move the token to.y
- The Y coordinate to move the token to.units
- If set tofalse
(0
), the coordinates are a location on the grid in cells. Defaults totrue
(1
), where the coordinates are in Distance Per Cell pixels.tokenRef
- Either the tokenid
or Token Name of the token to move, defaults to the Current Token.Note: This parameter can only be used in a Trusted Macro.
Token IDs are unique, but Token Names can be duplicated. Using Token Name when more than one token has the same name can produce unexpected results.
Examples
Moves the Current Token right
5
pixels, and up 10
pixels.
[h: CurrentX = getTokenX()]
[h: CurrentY = getTokenY()]
[h: NewX = CurrentX + 5]
[h: NewY = CurrentY - 10]
[h: moveToken(NewX, NewY)]
Moves the Current Token right 5
cells, and up 10
cells.
[h: CurrentX = getTokenX(0)]
[h: CurrentY = getTokenY(0)]
[h: NewX = CurrentX + 5]
[h: NewY = CurrentY - 10]
[h: moveToken(NewX, NewY, 0)]