macro (roll option): Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Redirect pending split of article.)
 
m (Initial copy-over.)
Line 1: Line 1:
#REDIRECT [[Macros:Branching and Looping]]
{{RollOption
[[Category:Roll Option]]
|name=macro
|version=1.3b46
|description=
Runs the named macro, returning its output in the form of the [[macro.return]] special variable.
 
|usage=
<source lang="mtmacro" line>
[macro("macro_name@location"): macro_arguments]
</source>
'''Parameters'''
{{param|macro_name|The name of the macro button that is run.}}
{{param|location|The location of the macro button that is run.}}
{{param|macro_arguments|Sent to the called macro in the form of the [[macro.args]] special variable.}}
'''Location Requirements'''
 
The {{code|location}} can be one of the following:
* {{code|TOKEN}} - The currently impersonated token (use the word {{code|TOKEN}}, not the token's name).
* Library Token - A [[Library Token]] in the current campaign.
* {{code|this}} - If the macro is calling another macro on the same [[Library Token]], {{code|this}} may be used instead of retyping the full [[Library Token]] name.
'''Notes'''
 
When a token macro calls another macro, the macro instructions in the ''called'' macro are executed against the ''calling'' token (in other words, the macro uses properties available on the calling token and applies all results to that token), unless the focus is explicitly changed to another token via either a roll option, or the {{func|switchToken}} function, or the {{func|getLibProperty}} function.
 
Also- as of at least 1.3.b50- a variable must be given for {{code|macro_arguments}}, or the ''"Could not execute the command: Undefined function: MACRO"'' error will result.  However, the variable given as {{code|macro_arguments}} doesn't have to be used, and can be set to an empty string ({{code|""}}).
 
|example=
<source lang="mtmacro" line>
[MACRO("getDamage@Lib:combat"): damageRoll]
</source>
Calls the macro {{code|getDamage}} which resides on a [[Library Token]] called {{code|Lib:combat}}, and passes the variable {{code|damageRoll}} as an argument to the called macro.
 
|also=
[[macro.args]],
[[macro.return]]
}}
[[Category:Branching Roll Option]]
[[Category:Branching Roll Option]]

Revision as of 03:37, 5 April 2009

[macro():] Roll Option

* Introduced in version 1.3b46

Runs the named macro, returning its output in the form of the macro.return special variable.

Usage

[macro("macro_name@location"): macro_arguments]

Parameters

  • macro_name - The name of the macro button that is run.
  • location - The location of the macro button that is run.
  • macro_arguments - Sent to the called macro in the form of the macro.args special variable.

Location Requirements

The location can be one of the following:

  • TOKEN - The currently impersonated token (use the word TOKEN, not the token's name).
  • Library Token - A Library Token in the current campaign.
  • this - If the macro is calling another macro on the same Library Token, this may be used instead of retyping the full Library Token name.

Notes

When a token macro calls another macro, the macro instructions in the called macro are executed against the calling token (in other words, the macro uses properties available on the calling token and applies all results to that token), unless the focus is explicitly changed to another token via either a roll option, or the switchToken() function, or the getLibProperty() function.

Also- as of at least 1.3.b50- a variable must be given for macro_arguments, or the "Could not execute the command: Undefined function: MACRO" error will result. However, the variable given as macro_arguments doesn't have to be used, and can be set to an empty string ("").

Example

[MACRO("getDamage@Lib:combat"): damageRoll]

Calls the macro getDamage which resides on a Library Token called Lib:combat, and passes the variable damageRoll as an argument to the called macro.

See Also

macro.args, macro.return