canSeeToken: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 13: | Line 13: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro"> | ||
canSeeToken(target) | canSeeToken(target) | ||
canSeeToken(target, source) | canSeeToken(target, source) | ||
</ | canSeeToken(target, source, mapRef) | ||
</syntaxhighlight> | |||
'''Parameters''' | '''Parameters''' | ||
{{param|target|Either the token | {{param|target|Either the token [[getSelected|{{code|id}}]] or [[getTokenName|Token Name]] of target token.}} | ||
{{param|source|Either the token | {{param|source|Either the token [[getSelected|{{code|id}}]] or [[getTokenName|Token Name]] of the source, i.e. viewing token.}} | ||
{{param|mapRef|The Name or ID of the map to find the two tokens. 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.}} | |||
|example= | |example= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
<!-- Dragon token partially hidden by VBL from current token. --> | <!-- Dragon token partially hidden by VBL from current token. --> | ||
[r: canSeeToken("Dragon")] | [r: canSeeToken("Dragon")] | ||
Line 31: | Line 34: | ||
[r: canSeeToken("Troll","Token")] | [r: canSeeToken("Troll","Token")] | ||
</ | </syntaxhighlight> | ||
Returns: | Returns: | ||
< | <syntaxhighlight lang="javascript"> | ||
["TOP_LEFT", "TOP_RIGHT", "CENTER"] | ["TOP_LEFT", "TOP_RIGHT", "CENTER"] | ||
[] | [] | ||
["TOP_LEFT", "BOTTOM_LEFT", "TOP_RIGHT", "BOTTOM_RIGHT", "CENTER"] | ["TOP_LEFT", "BOTTOM_LEFT", "TOP_RIGHT", "BOTTOM_RIGHT", "CENTER"] | ||
</ | </syntaxhighlight> | ||
|also= | |also= [[isVisible|isVisible()]] | ||
|changes= | |changes= | ||
{{change|1.5.4|Added {{code|mapname}} parameter option.}} | |||
}} | }} | ||
[[Category:Sight Function]] | [[Category:Sight Function]] | ||
[[Category:Token Function]] | [[Category:Token Function]] |
Latest revision as of 23:59, 11 May 2024
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
Usage
canSeeToken(target)
canSeeToken(target, source)
canSeeToken(target, source, mapRef)
Parameters
target
- Either the tokenid
or Token Name of target token.source
- Either the tokenid
or Token Name of the source, i.e. viewing token.mapRef
- The Name or ID of the map to find the two tokens. Defaults to the current map.
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.
Example
<!-- Dragon token partially hidden by VBL from current token. -->
[r: canSeeToken("Dragon")]
<!-- Troll token completely hidden from Elf token. -->
[r: canSeeToken("Troll","Elf")]
<!-- Troll token visible to Hero token. -->
[r: canSeeToken("Troll","Token")]
Returns:
["TOP_LEFT", "TOP_RIGHT", "CENTER"]
[]
["TOP_LEFT", "BOTTOM_LEFT", "TOP_RIGHT", "BOTTOM_RIGHT", "CENTER"]
See Also
Version Changes
- 1.5.4 - Added
mapname
parameter option.