Difference between revisions of "Macros/Nested Macros"
From Roll20 Wiki
Andreas J. (Talk | contribs) (transclude from Macro page, minor changes) |
Revision as of 13:48, 30 November 2021
Page Updated: 2021-11-30 |
Macro Creation
- Complete Guide to Macros & Rolls
- q Text Chat
- Dice Reference
- Order of Operations
- Macros
- Token Reference
- Character Reference
- Roll Templates
- Roll Table
Advanced
- Formatting
- HTML Replacement
- Chat Menus
- Hidden Rolls
- Advanced Macro Tips
- API Commands
- Char Sheet Creation
- External tools
Misc.
Macros can be nested inside each other, which gives the ability to combine macros, and call multiple macros with a single action. To nest a macro, simply include the name of the macro you wish to call on its own line inside your macro.
Example
In this example, we'll have three macros: #damage
, #attack
, and #both
Macro #damage
/roll 1d4+11
Macro #attack
:
/roll 1d20+9
Macro #both
:
#attack #damage
Nesting in a Roll Query
If you are nesting a macro in a Roll Query, make sure there is a space after the macro name, and no space between the ,
and #
so that it is properly recognized by Roll20.
?{Which macro?|Attack,#use-sword |Defend,#use-shield }
Troubleshooting
Due to the order of operations, Macro calls nested within Roll Query are fully expanded before the Roll Query is executed. This means that if a macro nested within a Roll Queries contains any "problematic characters" that conflict with Roll Query syntax (such as }
,
and |
), that nested macro may cause the Roll Query to break (because the Roll Query will treat problematic characters in the called macro as Roll Query syntax).
If this is the case, it may be necessary to either remove those problematic characters (within the called macro itself), or replace them with HTML Entities.
Macros which contain HTML replacement entities may no longer function outside of a Roll Query, and should be saved as Abilities.
Reopening a l Collections Macro reverts HTML entities; if that Macro is then saved, those reversions are as well. This behaviour is not present within Abilities.