macro (roll option): Difference between revisions
Verisimilar (talk | contribs) m (Initial copy-over.) |
(Added description of interaction with if roll option.) |
||
Line 24: | Line 24: | ||
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|""}}). | 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|""}}). | ||
This roll option may not interact with other roll options the way you expect. For example: | |||
<source lang="mtmacro" line> | |||
[if(Condition),MACRO("getDamage@Lib:combat"): damageRoll] | |||
</source> | |||
{{code|getDamage}} gets executed regardless of the value of {{code|Condition}}. However, if {{code|Condition}} is not true, the arguments to the macro will be empty instead of containing {{code|damageRoll}}. You probably want: | |||
<source lang="mtmacro" line> | |||
[if(Condition): evalMacro('[MACRO("getDamage@Lib:combat"): damageRoll]')] | |||
</source> | |||
|example= | |example= |
Revision as of 19:00, 26 May 2009
[macro():] Roll Option
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 wordTOKEN
, 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 (""
).
This roll option may not interact with other roll options the way you expect. For example:
[if(Condition),MACRO("getDamage@Lib:combat"): damageRoll]
getDamage
gets executed regardless of the value of Condition
. However, if Condition
is not true, the arguments to the macro will be empty instead of containing damageRoll
. You probably want:
[if(Condition): evalMacro('[MACRO("getDamage@Lib:combat"): damageRoll]')]
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.