getTokenX: Difference between revisions
No edit summary |
No edit summary |
||
(15 intermediate revisions by 7 users not shown) | |||
Line 6: | Line 6: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
getTokenX() | getTokenX() | ||
getTokenX(units) | getTokenX(units) | ||
getTokenX(units, tokenRef) | |||
getTokenX(units, tokenRef, mapname) | |||
getTokenX(units, | </syntaxhighlight> | ||
</ | |||
'''Parameters''' | '''Parameters''' | ||
{{param|units|If set to {{false}}, the coordinate is a location on the grid in number of ''cells''. Defaults to {{true}}, where the coordinate is in ''number of Pixels'' (in other words 0:distance in cells, 1: distance in pixels)'.}} | |||
{{param|tokenRef|Either the token [[getSelected|{{code|id}}]] or [[getTokenName|Token Name]] of the token to return the X coordinate of, defaults to the [[Current Token]].}} | |||
{{param|mapname|The name of the map to find the token. Defaults to the current map.}} | |||
{{Note|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.}} | |||
'''Which coordinate is returned for tokens larger then one cell''' | '''Which coordinate is returned for tokens larger then one cell''' | ||
* 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. | {{ProposedChange|The {{mark}}marked exception will disappear.}} | ||
* 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 | * With the exception of {{mark}}one case the coordinates of the cell are given where the UPPER LEFT CORNER of the the image of the token is in at that moment. | ||
* {{mark}}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 upper left corner of the FOOTPRINT (NOT image) of the token is at. The footprint can be recognized when you move the token on the Token layer, it will leave the white marker on the field. The footprint can be the same size as the image and it is if a preset size is used. With freesize however the size of the footprint is either the original size of the image OR when you have used a preset (e.g. 'large') it will have the size of the preset as footprint. | |||
* 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. | * 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= | ||
Moves the [[Current Token]] | Moves the [[Current Token]] right {{code|5}} '''pixels''', and up {{code|10}} '''pixels'''. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: CurrentX = getTokenX()] | [h: CurrentX = getTokenX()] | ||
[h: CurrentY = getTokenY()] | [h: CurrentY = getTokenY()] | ||
Line 32: | Line 32: | ||
[h: NewY = CurrentY - 10] | [h: NewY = CurrentY - 10] | ||
[h: moveToken(NewX, NewY)] | [h: moveToken(NewX, NewY)] | ||
</ | </syntaxhighlight> | ||
Moves the [[Current Token]] | Moves the [[Current Token]] right {{code|5}} '''cells''', and up {{code|10}} '''cells'''. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: CurrentX = getTokenX(0)] | [h: CurrentX = getTokenX(0)] | ||
[h: CurrentY = getTokenY(0)] | [h: CurrentY = getTokenY(0)] | ||
Line 41: | Line 41: | ||
[h: NewY = CurrentY - 10] | [h: NewY = CurrentY - 10] | ||
[h: moveToken(NewX, NewY, 0)] | [h: moveToken(NewX, NewY, 0)] | ||
</ | </syntaxhighlight> | ||
|also= | |also= | ||
{{func|moveToken}}, | {{func|moveToken}}, | ||
{{func|getTokenY}} | {{func|getTokenY}}, | ||
{{func|getZoom}}, | |||
{{func|setZoom}}. | |||
|changes= | |||
{{change|1.5.8|Added {{code|mapname}} parameter option.}} | |||
}} | }} | ||
[[Category:Distance Function]] | [[Category:Distance Function]] [[Category:Token Function]] |
Latest revision as of 16:40, 14 May 2024
getTokenX() Function
Usage
getTokenX()
getTokenX(units)
getTokenX(units, tokenRef)
getTokenX(units, tokenRef, mapname)
Parameters
units
- If set tofalse
(0
), the coordinate is a location on the grid in number of cells. Defaults totrue
(1
), where the coordinate is in number of Pixels (in other words 0:distance in cells, 1: distance in pixels)'.tokenRef
- Either the tokenid
or Token Name of the token to return the X coordinate of, defaults to the Current Token.mapname
- The name of the map to find the token. Defaults to the current map.
Which coordinate is returned for tokens larger then one cell
Note: This refers to a proposed change that has not been implemented in the main code base yet.
Details:
The
∗
marked exception will disappear.
- With the exception of
∗ one case the coordinates of the cell are given where the UPPER LEFT CORNER of the the image 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 upper left corner of the FOOTPRINT (NOT image) of the token is at. The footprint can be recognized when you move the token on the Token layer, it will leave the white marker on the field. The footprint can be the same size as the image and it is if a preset size is used. With freesize however the size of the footprint is either the original size of the image OR when you have used a preset (e.g. 'large') it will have the size of the preset as footprint.
- 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
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)]
See Also
Version Changes
- 1.5.8 - Added
mapname
parameter option.