RPTools

Personal tools
From MapToolDoc

isVisible

isVisible() Function

Introduced in version 1.3b69

check whether a point on the map is visible from a token or not. It returns 1 is the token is visible, 0 otherwise. This vision is based off of the impersonated token.

Usage

  1. isVisible(x,y)
  1. isVisible(x,y,id)

Parameter

  • x - Then tokens x coordinate. Always in map units, not grid .
  • y - Then tokens x coordinate. Always in map units, not grid .
  • id - The check for visibility is performed from token id.  Note: This parameter can only be used in a Trusted Macro

Example

A simple example for testing out isVisible(). Drop the default tokens "Hero" and "Troll" on a map. Make sure "Hero" has sight (make him PC or set sight manually). You can then execute the following code as a campaign macro to check if the Hero can see the Troll.

  1. <!-- lets check if token1 can see token2 -->
  2. [h: token1 = "Hero"]
  3. [h: id1 = findToken(token1)]
  4.  
  5. [h: token2 = "Troll"]
  6. [h: id2 = findToken(token2)]
  7.  
  8. <!-- get the map coordinates of token2 -->
  9. <!-- i want to check if the center of the occupied cell can be seen -->
  10. <!-- getTokenX/Y retrieves the top-left corner, so -->
  11. <!-- in a 50 pixel grid the center is offset by 25 pixel -->
  12. [h: x = getTokenX(1, id2)+25]
  13. [h: y = getTokenY(1, id2)+25]
  14.  
  15. <!-- and final the check for visiblity -->
  16. [r:getName(id1)] <b>[r, if(isVisible(x,y, id1)): "can"; "cannot"]</b> see [r:getName(id2)].