impersonate: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(6 intermediate revisions by 3 users not shown)
Line 5: Line 5:
|compatibility=1.7.0
|compatibility=1.7.0
|description=
|description=
Impersonate changes the impersonated token for the client running the function, replacing any current impersonation. Rather than being used like {{func|switchToken}} to aid in macro execution, this function is the same as right-clicking a token and selecting 'Impersonate'.
Impersonate changes the impersonated token for the client running the function, replacing any current impersonation. Rather than being used like {{func|switchToken}} to aid in macro execution, this function is the same as right-clicking a token and selecting 'Impersonate'.  The function does '''not''' set the [[Current Token]].  Use {{func|switchToken}} for that.


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
impersonate(id)
impersonate(tokenRef)
</source>
</syntaxhighlight>
'''Parameters'''
'''Parameters'''
{{param|id|The id or name of the token to impersonate.}}
{{param|tokenRef|Either the token [[getSelected|{{code|id}}]] or [[getTokenName|Token Name]] of the token to impersonate.}}
{{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=
You can use Impersonate to simulate multiple tokens speaking in turn:
Calling {{func|impersonate}} in a macro will cause the output to be as if from that token. The last call to {{func|impersonate}} in a macro sets the "speaker" for the output of the whole macro.
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: impersonate("Hero")]Hi!<br>
[h: impersonate("Hero")]Hi!<br>
[h: impersonate("Elf")]Hi!<br>
Nice weather, eh?<br>
[h: impersonate("Mystic")]Hi!<br>
Seen any dragons?
[h: impersonate("Wolf")]Burp!
</syntaxhighlight>
</source>
Output:
Output:
[[Image:func_impersonate_example1.png]]
[[File:Func_impersonate_example1.png]]





Latest revision as of 15:41, 17 May 2024

impersonate() Function

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

Introduced in version 1.7.0
Last checked for compatibility with version 1.7.0
Impersonate changes the impersonated token for the client running the function, replacing any current impersonation. Rather than being used like switchToken() to aid in macro execution, this function is the same as right-clicking a token and selecting 'Impersonate'. The function does not set the Current Token. Use switchToken() for that.

Usage

impersonate(tokenRef)

Parameters

  • tokenRef - Either the token id or Token Name of the token to impersonate.
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

Calling impersonate() in a macro will cause the output to be as if from that token. The last call to impersonate() in a macro sets the "speaker" for the output of the whole macro.
[h: impersonate("Hero")]Hi!<br>
Nice weather, eh?<br>
Seen any dragons?

Output:

See Also

Version Changes

  • 1.7.0 - Introduced.