moveToken: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Add 'See Also' bullets from moveTokenTo/FromMap)
mNo edit summary
Line 19: Line 19:
<!-- The 'nbsp' is needed to close the DIV -->
<!-- The 'nbsp' is needed to close the DIV -->
|examples=
|examples=
Moves the [[Current Token]] down {{code|5}} '''units''', and left {{code|10}} '''units'''.
Moves the [[Current Token]] right {{code|5}} '''units''', and up {{code|10}} '''units'''.
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: CurrentX = getTokenX()]
[h: CurrentX = getTokenX()]
Line 28: Line 28:
</source>
</source>


Moves the [[Current Token]] down {{code|5}} '''cells''', and left {{code|10}} '''cells'''.
Moves the [[Current Token]] right {{code|5}} '''cells''', and up {{code|10}} '''cells'''.
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: CurrentX = getTokenX(0)]
[h: CurrentX = getTokenX(0)]

Revision as of 07:02, 25 August 2022

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, id)

Parameters

  • x - The X coordinate to move the token to.
  • y - The Y coordinate to move the token to.
  • units - If set to false(0), the coordinates are a location on the grid in cells. Defaults to true(1), where the coordinates are in Distance Per Cell pixels.
  • id - The id string of the token to move, defaults to the Current Token.

     Note: This parameter can only be used in a Trusted Macro

 

Examples

Moves the Current Token right 5 units, and up 10 units.
[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)]

See Also