canSeeToken: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page CanSeeToken to canSeeToken: Converting page titles to lowercase)
m (Text replacement - "source>" to "syntaxhighlight>")
Line 17: Line 17:
canSeeToken(target, source)
canSeeToken(target, source)
canSeeToken(target, source, mapname)
canSeeToken(target, source, mapname)
</source>
</syntaxhighlight>
'''Parameters'''
'''Parameters'''
{{param|target|Either the token ID or name of the target token.}}
{{param|target|Either the token ID or name of the target token.}}
Line 33: Line 33:
[r: canSeeToken("Troll","Token")]
[r: canSeeToken("Troll","Token")]


</source>
</syntaxhighlight>
Returns:
Returns:
<source lang="javascript">
<source lang="javascript">
Line 39: Line 39:
[]
[]
["TOP_LEFT", "BOTTOM_LEFT", "TOP_RIGHT", "BOTTOM_RIGHT", "CENTER"]
["TOP_LEFT", "BOTTOM_LEFT", "TOP_RIGHT", "BOTTOM_RIGHT", "CENTER"]
</source>
</syntaxhighlight>


|also= [[isVisible|isVisible()]]
|also= [[isVisible|isVisible()]]

Revision as of 17:46, 14 March 2023

canSeeToken() Function

Introduced in version 1.3b77
Returns a json array of the points visible on the target token from the source token as an enumerated list. Default source is Current Token. The enumerated list will contain zero to five of the following values:
  • TOP_RIGHT
  • BOTTOM_RIGHT
  • TOP_LEFT
  • BOTTOM_LEFT
  • CENTER
When a token is not visible, an empty json array is returned: '[]'

Usage

<source lang="mtmacro"> canSeeToken(target) canSeeToken(target, source) canSeeToken(target, source, mapname) </syntaxhighlight> Parameters

  • target - Either the token ID or name of the target token.
  • source - Either the token ID or name of the source, i.e. viewing token.
  • mapname - The name of the map to find the two tokens. Defaults to the current map.

Example

<source lang="mtmacro" line>

[r: canSeeToken("Dragon")] [r: canSeeToken("Troll","Elf")] [r: canSeeToken("Troll","Token")]

</syntaxhighlight> Returns: <source lang="javascript"> ["TOP_LEFT", "TOP_RIGHT", "CENTER"] [] ["TOP_LEFT", "BOTTOM_LEFT", "TOP_RIGHT", "BOTTOM_RIGHT", "CENTER"]

</syntaxhighlight>

See Also

Version Changes

  • 1.5.4 - Added mapname parameter option.