macroLink: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Added version.)
(Updated for new features in b55, added see also.)
Line 30: Line 30:
** ''all'' - everyone (acts like a [[SlashCommands:say|/say]])
** ''all'' - everyone (acts like a [[SlashCommands:say|/say]])
** ''none'' - discard any output.
** ''none'' - discard any output.
** ''gm-self'' - Display to GM and the person executing the link.
** ''list'' - Displays to a list of players. When ''output'' is {{code|list}} then the macro link expects the argument to be a [[JSON Object]], that contains a field called {{code|mlOutputList}} which is a [[JSON Array]] containing the players to send the output to.
* ''args'' Any arguments to be passed to the macro when it is called.
* ''args'' Any arguments to be passed to the macro when it is called.
* ''target'' Which tokens to run the macro on. Target can be one or more of the following separated by commas (defaults to ''impersonated'')
* ''target'' Which tokens to run the macro on. Target can be one or more of the following separated by commas (defaults to ''impersonated'')
Line 45: Line 47:
<a href="macro://Test@Lib:Test/gm/impersonated?count=6;">Click on me!</a>
<a href="macro://Test@Lib:Test/gm/impersonated?count=6;">Click on me!</a>
</source>
</source>
Sending to multiple players and the GM in 1.3b55
<source lang="mtmacro" lines>
[h: outputTo = '["Fred", "Barney", "gm"]']
[h: args = json.set("{}", "mlOutputList")]
[r: macroLink("Click on me!", "Test@Lib:Test", "list", args)]
</source>
|also=
{{func|macroLinkText}}
|changes=
* '''1.3b55''' - added {{code|gm-self}} and {{code|list}} output options.
}}
}}
[[Category:Miscellaneous Function]]
[[Category:Miscellaneous Function]]

Revision as of 01:08, 13 April 2009

macroLink() Function

Introduced in version 1.3b48
Creates the HTML for a link which will run the specified macro when clicked on.

Usage

macroLink(text, macroName)
macroLink(text, macroName, output)
macroLink(text, macroName, output, args)
macroLink(text, macroName, output, args, target)

The string generated by the macroLink function follows this format:

<a href="macro://macroName/output/target?args">text</a>

  • text is the text to display for the link.
  • macroName is the name of the macro to run when the link is clicked. The macroName is in the same format that is used for [macro(...): ...] e.g. Test@Lib:test
  • output contains who the output of the macro should go to, values are (defaults to none)
    • self - Display only to person who clicked on the link.
    • gm - Display to GM.
    • all - everyone (acts like a /say)
    • none - discard any output.
    • gm-self - Display to GM and the person executing the link.
    • list - Displays to a list of players. When output is list then the macro link expects the argument to be a JSON Object, that contains a field called mlOutputList which is a JSON Array containing the players to send the output to.
  • args Any arguments to be passed to the macro when it is called.
  • target Which tokens to run the macro on. Target can be one or more of the following separated by commas (defaults to impersonated)

Examples

To create a link that will call a macro called Test on the Library Token named Lib:Test that says "Click on me!" and displays the output to the GM.
[r: macroLink("Click on me!", "Test@Lib:Test", "gm", "count=6", "impersonated")]

produces this output:

<a href="macro://Test@Lib:Test/gm/impersonated?count=6;">Click on me!</a>

Sending to multiple players and the GM in 1.3b55

[h: outputTo = '["Fred", "Barney", "gm"]']
[h: args = json.set("{}", "mlOutputList")]
[r: macroLink("Click on me!", "Test@Lib:Test", "list", args)]

See Also

Version Changes

  • 1.3b55 - added gm-self and list output options.