token.visible: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
 
(6 intermediate revisions by 3 users not shown)
Line 5: Line 5:
===Getting Token Visibility===
===Getting Token Visibility===


<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[token.visible]
[token.visible]
</source>
</syntaxhighlight>


Will return 1 if the token is currently "Visible to players," and 0 if it is not.  
Will return 1 if the token is currently "Visible to players," and 0 if it is not.  
Line 13: Line 13:
===Setting Token Visibility===
===Setting Token Visibility===


<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[token.visible = 0]
[token.visible = 0]
</source>
</syntaxhighlight>


Will set ''token.visible'' to 0 - ''e.g.'', making the token invisible to players. A more useful approach might be:
Will set ''token.visible'' to 0 - ''e.g.'', making the token invisible to players. A more useful approach might be:


<source lang="mtmacro" line>
<syntaxhighlight  lang="mtmacro" line>
[token.visible = 1 - token.visible]
[token.visible = 1 - token.visible]
</source>
</syntaxhighlight>


This creates a "toggle" macro that will alternate ''token.visible'' between its two possible values each time the button is clicked.
This creates a "toggle" macro that will alternate ''token.visible'' between its two possible values each time the button is clicked.
Line 27: Line 27:
==Related Pages==
==Related Pages==


* [[Macros:Variables:list_of_special_variables|List of Special Variables]]
[[Category:Special Variable]]
[[Category:Macro Function]]

Latest revision as of 23:59, 4 July 2023

The variable token.visible controls the visibility of the token to players during a game. The variable can take two values, 0 (not visible) or 1 (visible to players). This is equivalent to the "Visible to players" option on the right-click menu for tokens.

Examples

Getting Token Visibility

[token.visible]

Will return 1 if the token is currently "Visible to players," and 0 if it is not.

Setting Token Visibility

[token.visible = 0]

Will set token.visible to 0 - e.g., making the token invisible to players. A more useful approach might be:

[token.visible = 1 - token.visible]

This creates a "toggle" macro that will alternate token.visible between its two possible values each time the button is clicked.

Related Pages