macroLink: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Macros:Functions:macroLink moved to macroLink: Moved out of Macros namespace.)
m (Added MacroFunction template and Miscellaneous Function category)
Line 1: Line 1:
==Function macroLink==
{{MacroFunction
 
|name=macroLink
|description=
Creates the HTML for a link which will run the specified macro when clicked on.
Creates the HTML for a link which will run the specified macro when clicked on.


 
|usage=
 
 
===Usage===
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[r: link = macroLink(text, macroName)]
[r: link = macroLink(text, macroName)]
Line 31: Line 29:
** ''[[Token:Token Id|Token Id]]'' - the ''[[Token:Token Id|id]] of a [[Token:Token|Token]].
** ''[[Token:Token Id|Token Id]]'' - the ''[[Token:Token Id|id]] of a [[Token:Token|Token]].


===Examples===
|examples=
To create a link that will call a macro called Test on the [[Token:library_token|Library Token]] named Lib:Test that says "''Click on me!''" and displays the output to the GM.
To create a link that will call a macro called Test on the [[Token:library_token|Library Token]] named Lib:Test that says "''Click on me!''" and displays the output to the GM.
<source lang="mtmacro">
<source lang="mtmacro">
Line 40: Line 38:
<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>
}}
[[Category:Miscellaneous Function]]

Revision as of 02:52, 9 March 2009

macroLink() Function

Creates the HTML for a link which will run the specified macro when clicked on.

Usage

[r: link = macroLink(text, macroName)]
[r: link = macroLink(text, macroName, output)]
[r: link = macroLink(text, macroName, output, args)]
[r: link = 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.
  • 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>