switchToken: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Fixing wikilink)
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 7: Line 7:
<p>In practice, "the remainder of the Macro" is the same as the variable scope. Thus, if a macro is running as a user defined function (see {{func|defineFunction}}  ) with a new scope, switchToken will only apply until the end of the current macro. Once control passes back to the calling macro, the [[Current Token]] reverts back to what it was before the external macro was called ( as a function ).
<p>In practice, "the remainder of the Macro" is the same as the variable scope. Thus, if a macro is running as a user defined function (see {{func|defineFunction}}  ) with a new scope, switchToken will only apply until the end of the current macro. Once control passes back to the calling macro, the [[Current Token]] reverts back to what it was before the external macro was called ( as a function ).
If a {{func|defineFunction}} does not create a new variable scope for the called macro, then effects of switchToken persist when control passes back to the calling macro.</p>
If a {{func|defineFunction}} does not create a new variable scope for the called macro, then effects of switchToken persist when control passes back to the calling macro.</p>
'''Note: You cannot switch to a token on a different map.'''


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
switchToken(tokenId)
switchToken(tokenId)
</source>
</syntaxhighlight>
}}
}}
[[Category:Token Function]]
[[Category:Token Function]]

Latest revision as of 17:29, 14 March 2023

switchToken() Function

 Note: This function can only be used in a Trusted Macro

Introduced in version 1.3b48
Changes the Current Token for the remainder of the Macro.

In practice, "the remainder of the Macro" is the same as the variable scope. Thus, if a macro is running as a user defined function (see defineFunction() ) with a new scope, switchToken will only apply until the end of the current macro. Once control passes back to the calling macro, the Current Token reverts back to what it was before the external macro was called ( as a function ). If a defineFunction() does not create a new variable scope for the called macro, then effects of switchToken persist when control passes back to the calling macro.

Note: You cannot switch to a token on a different map.

Usage

switchToken(tokenId)