switchToken: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page switchToken to SwitchToken without leaving a redirect: Converting page title to first-letter uppercase)
No edit summary
 
(One intermediate revision by one other user not shown)
Line 11: Line 11:


|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)