movedOverPoints

From RPTools Wiki
Revision as of 02:19, 29 March 2019 by Phergus (talk | contribs)
Jump to navigation Jump to search

 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
Use to check if a token has moved through a shape that is defined by an array of pixel coordinates (formatted like the one received from getLastPath() or the onTokenMove events macro.args.

Returns a JSON array with coordinates of all cells that are

  • all or partially in the defined shape and
  • were traversed by the token.

Where each point is dependent on the grid type:

  • Square: Coordinates are the top-left corner.
  • Hex: Coordinates are the center point of the cell.
  • Isometric: Coordinates are the right-most point of the cell.
  • Gridless: Returns just the top-left corner of the token's ending location.

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)]