movedOverPoints: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
(More in compliance with function template.) |
||
Line 4: | Line 4: | ||
|version=1.3.b75 | |version=1.3.b75 | ||
|description= | |description= | ||
Is used to check if a token has moved through a shape that is defined by an array of cell coordinates (formatted like the one received from {{func|getLastPath}} or the {{code|onTokenMove}} events {{code|macro.args}} | Is used to check if a token has moved through a shape that is defined by an array of cell coordinates (formatted like the one received from {{func|getLastPath}} or the {{code|onTokenMove}} events {{code|macro.args}}. | ||
{{code|movedOverPoints}} returns a JSON array with coordinates of all cells that have been a) in the defined shape and b) traversed by the token. | {{code|movedOverPoints}} returns a JSON array with coordinates of all cells that have been a) in the defined shape and b) traversed by the token. | ||
|usage= | |usage= | ||
<source lang="mtmacro" line> | |||
movedOverPoints(points) | |||
</source> | |||
'''Parameters''' | |||
{{param|points|JSON array of cell coordinate X/Y pairs that defines a polygon}} | |||
|example= | |||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
<!-- lets define a shape --> | <!-- lets define a shape --> | ||
Line 16: | Line 24: | ||
json.set("", "x", 0, "y", 100), | json.set("", "x", 0, "y", 100), | ||
json.set("", "x", 100, "y", 100), | json.set("", "x", 100, "y", 100), | ||
json.set("", "x", | json.set("", "x", 100, "y", 0) | ||
)] | )] | ||
<!-- check if token in context has moved through that shape --> | <!-- check if token in context has moved through that shape --> | ||
[r: movedOverPoints(jsonArray)] | [r: movedOverPoints(jsonArray)] | ||
</source> | </source> | ||
}} | }} | ||
[[Category:Miscellaneous Function]] | [[Category:Miscellaneous Function]] |
Revision as of 23:13, 28 March 2019
This article is a stub, you can help the RPTools Wiki project by contributing content to expand this article.
This article needs: lastPath-format specified, define/explain return value, examples
movedOverPoints() Function
• Introduced in version 1.3.b75
Is used to check if a token has moved through a shape that is defined by an array of cell coordinates (formatted like the one received from getLastPath() or the
onTokenMove
events macro.args
.
movedOverPoints
returns a JSON array with coordinates of all cells that have been a) in the defined shape and b) traversed by the token.Usage
movedOverPoints(points)
Parameters
points
- JSON array of cell coordinate X/Y pairs that defines a polygon
Example
<!-- lets define a shape -->
[h: jsonArray = json.append("",
json.set("", "x", 0, "y", 0),
json.set("", "x", 0, "y", 100),
json.set("", "x", 100, "y", 100),
json.set("", "x", 100, "y", 0)
)]
<!-- check if token in context has moved through that shape -->
[r: movedOverPoints(jsonArray)]