macroLinkText: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (If I'm interpreting the changes correctly, the new example had an error in it.)
m (Clarified list option for output parameter.)
Line 26: Line 26:
** {{code|none}} - Discard any output.
** {{code|none}} - Discard any output.
** {{code|gm-self}} - Display to GM and the person executing the link.
** {{code|gm-self}} - Display to GM and the person executing the link.
** {{code|list}} - Displays to a list of players. When the {{code|output}} parameter 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.
** {{code|list}} - Displays to a list of players. When the {{code|output}} parameter is {{code|"list"}} then the macro link expects the {{code|args}} parameter 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.
{{param|args|Any arguments to be passed to the macro when it is called.}}
{{param|args|Any arguments to be passed to the macro when it is called.}}
{{param|target|Which tokens to run the macro on. Target can be one or more of the following separated by commas (defaults to {{code|impersonated}}):}}
{{param|target|Which tokens to run the macro on. Target can be one or more of the following separated by commas (defaults to {{code|impersonated}}):}}

Revision as of 16:42, 15 April 2009

macroLinkText() Function

Introduced in version 1.3b48
Creates the text that would appear in a HTML tag for a link which will run the specified macro when clicked on. This is useful for callbacks in dialog()s or frame()s. If you just want to send a click-able link to someone use macroLink().

Usage

macroLinkText(macroName)
macroLinkText(macroName, output)
macroLinkText(macroName, output, args)
macroLinkText(macroName, output, args, target)

Parameters

  • macroName - The name of the macro to run when the link is clicked. The macroName is in the standard macro reference format (e.g. Macro@Lib:Token)
  • output - 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 the output parameter is "list" then the macro link expects the args parameter 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 the text that would go inside a form element as the action attribute, and that will call a macro named Test on the Library Token named Lib:Test:
[r: macroLinkText("Test@Lib:Test","", "gm")]

Returns: macro://Test@Lib:Test/gm/impersonated?

To create the text that would go inside a form element as the action attribute and call the AddWeapon on the Library Token named Lib:PC which will act upon the Current Token:

[r:macroLinkText('AddWeapon@Lib:PC', 'none', '', currentToken())]

Returns: macro://AddWeapon@Lib:PC/none/#ID#? where #ID# is the id of the Current Token.

Sending to multiple players and the GM in 1.3b55

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

See Also

Version Changes

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