macro (roll option): Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Added description of interaction with if roll option.)
mNo edit summary
Line 21: Line 21:
'''Notes'''
'''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.
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 within the ''called'' macro. This applies even if the [[Current Token]] was explicitly changed prior to using the {{roll|macro}} roll option.


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|""}}).

Revision as of 06:20, 4 June 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 within the called macro. This applies even if the Current Token was explicitly changed prior to using the [macro():] roll option.

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.

See Also

macro.args, macro.return