moveToken: Difference between revisions
Jump to navigation
Jump to search
Verisimilar (talk | contribs) m (Added clarification request.) |
m (Changed "Macros:Variables:string" to "string" so redirect can be removed) |
||
(14 intermediate revisions by 9 users not shown) | |||
Line 1: | Line 1: | ||
{{MacroFunction | {{MacroFunction | ||
|name=moveToken | |name=moveToken | ||
Line 7: | Line 6: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
moveToken(x, y) | moveToken(x, y) | ||
moveToken(x, y, units) | moveToken(x, y, units) | ||
moveToken(x, y, units, id) | moveToken(x, y, units, id) | ||
</ | </syntaxhighlight> | ||
'''Parameters''' | '''Parameters''' | ||
* {{code|x}} - The X coordinate to move the token to. | * {{code|x}} - The X coordinate to move the token to. | ||
* {{code|y}} - The Y coordinate to move the token to. | * {{code|y}} - The Y coordinate to move the token to. | ||
* {{code|units}} - If set to {{false}}, the coordinates are a location on the grid in '''cells'''. Defaults to {{true}}, where the coordinates are in ''Distance Per Cell'' '''pixels'''. | |||
* {{code|units}} - If set to {{ | * {{code|id}} - The id [[string]] of the token to move, defaults to the [[Current Token]].{{TrustedParameter}} | ||
* {{code|id}} - The id of the token to move, defaults to the | | ||
<!-- The 'nbsp' is needed to close the DIV --> | |||
|examples= | |||
Moves the [[Current Token]] right {{code|5}} '''pixels''', and up {{code|10}} '''pixels'''. | |||
<syntaxhighlight lang="mtmacro" line> | |||
[h: CurrentX = getTokenX()] | |||
[h: CurrentY = getTokenY()] | |||
[h: NewX = CurrentX + 5] | |||
[h: NewY = CurrentY - 10] | |||
[h: moveToken(NewX, NewY)] | |||
</syntaxhighlight> | |||
Moves the [[Current Token]] right {{code|5}} '''cells''', and up {{code|10}} '''cells'''. | |||
<syntaxhighlight lang="mtmacro" line> | |||
[h: CurrentX = getTokenX(0)] | |||
[h: CurrentY = getTokenY(0)] | |||
[h: NewX = CurrentX + 5] | |||
[h: NewY = CurrentY - 10] | |||
[h: moveToken(NewX, NewY, 0)] | |||
</syntaxhighlight> | |||
|also= | |||
{{func|getTokenX}}, | |||
{{func|getTokenY}}, | |||
{{func|moveTokenToMap}}, | |||
{{func|moveTokenFromMap}} | |||
}} | }} | ||
[[Category:Token Function]] | [[Category:Token Function]] |
Revision as of 07:13, 23 November 2023
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 tofalse
(0
), the coordinates are a location on the grid in cells. Defaults totrue
(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
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)]