getTokenX: Difference between revisions
Jump to navigation
Jump to search
Verisimilar (talk | contribs) mNo edit summary |
Verisimilar (talk | contribs) m (Added examples and some clarification.) |
||
Line 1: | Line 1: | ||
{{MacroFunction | {{MacroFunction | ||
|name=getTokenX | |name=getTokenX | ||
Line 17: | Line 16: | ||
</source> | </source> | ||
'''Parameters''' | '''Parameters''' | ||
* {{code|units}} - If set to {{ | * {{code|units}} - If set to {{false}}, the coordinate is a location on the grid in '''cells'''. Defaults to {{true}}, where the coordinate is in ''Distance Per Cell'' '''units'''. | ||
* {{code|id}} - The | * {{code|id}} - The id of the token to move, defaults to the [[Current Token]]. | ||
|examples= | |||
Moves the [[Current Token]] down {{code|5}} '''units''', and left {{code|10}} '''units'''. | |||
<source lang="mtmacro" line> | |||
[h: CurrentX = getTokenX()] | |||
[h: CurrentY = getTokenY()] | |||
[h: NewX = CurrentX + 5] | |||
[h: NewY = CurrentY - 10] | |||
[h: moveToken(NewX, NewY)] | |||
</source> | |||
Moves the [[Current Token]] down {{code|5}} '''cells''', and left {{code|10}} '''cells'''. | |||
<source lang="mtmacro" line> | |||
[h: CurrentX = getTokenX(0)] | |||
[h: CurrentY = getTokenY(0)] | |||
[h: NewX = CurrentX + 5] | |||
[h: NewY = CurrentY - 10] | |||
[h: moveToken(NewX, NewY, 0)] | |||
</source> | |||
|also= | |||
{{func|moveToken}}, | |||
{{func|getTokenY}} | |||
}} | }} | ||
[[Category:Distance Function]] | [[Category:Distance Function]] |
Revision as of 11:59, 29 April 2009
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.id
- The id of the token to move, defaults to the Current Token.
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)]