execLink: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Made note about how deferred links are queued.)
No edit summary
Line 12: Line 12:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
execLink(link)
execLink(link)
</source>
<source lang="mtmacro" line>
execLink(link, defer)
execLink(link, defer)
execLink(link, defer, targets)
execLink(link, defer, targets, delim)
</source>
</source>
'''Parameters'''
'''Parameters'''
{{param|link|The link to "execute".}}
{{param|link|The link to "execute".}}
{{param|defer|Executes the link after the current macro has completed if non zero, defaults to zero.}}
{{param|defer|Executes the link after the current macro has completed if non zero, defaults to zero.}}
{{param|targets|are the user names (so not token names) but the names of the users that are logged in. The options "gm", "self-gm", "self", "none", and "all" are also valid parameters to give. E.g.: "tim, tom, tarra". Defaults to self (so if no parameter is given the link is executed locally only).}}
{{param|delim|The delimiter used to separate the values in the String List that is given, defaults to {{code|","}}. If {{code|"json"}} is specified, a JSON array is expected instead of a String List.}}


|examples=
|examples=
Execute a macro link immediatly (any output wil appear before the current macros output)
Execute a macro link immediately (any output will appear before the current macros output)
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: link = macroLinkText("Test@Lib:Test", "self")]
[h: link = macroLinkText("Test@Lib:Test", "self")]
Line 39: Line 42:
[h: execLink(link)]
[h: execLink(link)]
</source>
</source>
Execute a macro link on all client
<source lang="mtmacro" line>
[h: link = macroLinkText("Test@Lib:Test", "self")]
[h: execLink(link, 0, "all")]
</source>
|changes=
{{change|1.5.5|Added the {{code|targets}} and {{code|delim}} parameters.}}


|also=
|also=

Revision as of 15:24, 20 September 2019

execLink() Function

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

Introduced in version 1.3b55
Executes a macro link that was created with macroLinkText(), output generated by the link is sent to players using the standard macroLinkText() logic. execLink() allows you to defer the running of the link until after the currently running macro has ended in which case the output will be displayed after any output generated by the current macro. If you defer a series of links, they will be queued in order and executed after the currently running macro. There is no software limit to the amount of links you can queue, but your hardware will impose its own limitations. If the execution of the link is not defered then any output generated will appear before any output generated by the current macro. You can use this function to update values in a token copied with copyToken() using the defered option. You can also use this function to send output selectivly to a list of players from the current macro, or to generate output that is not suppressed when the abort() function is called.

Usage

execLink(link)
execLink(link, defer)
execLink(link, defer, targets)
execLink(link, defer, targets, delim)

Parameters

  • link - The link to "execute".
  • defer - Executes the link after the current macro has completed if non zero, defaults to zero.
  • targets - are the user names (so not token names) but the names of the users that are logged in. The options "gm", "self-gm", "self", "none", and "all" are also valid parameters to give. E.g.: "tim, tom, tarra". Defaults to self (so if no parameter is given the link is executed locally only).
  • delim - The delimiter used to separate the values in the String List that is given, defaults to ",". If "json" is specified, a JSON array is expected instead of a String List.

Examples

Execute a macro link immediately (any output will appear before the current macros output)
[h: link = macroLinkText("Test@Lib:Test", "self")]
[h: execLink(link)]

Execute a macro link after the execution of the current macro (any output will appear before the current macros output)

[h: link = macroLinkText("Test@Lib:Test", "self")]
[h: execLink(link, 1)]

Copy a token and update its values.

[h: newToken = copyToken("Hero")]
[h: link = macroLinkText("update@Lib:GM", "none", "", newToken)]
[h: execLink(link)]

Execute a macro link on all client

[h: link = macroLinkText("Test@Lib:Test", "self")]
[h: execLink(link, 0, "all")]

See Also

Version Changes

  • 1.5.5 - Added the targets and delim parameters.