Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Invoking a Macro/Ability from another Macro

Ok, so #macroname calls another macro. Example: A secret roll of d20! #Secret1d20 Runs a macro, including whisper command, etc. Just make sure the #macro is in a seperate line. Inside a Query: ?{WhatDefense?|Dodge,#MacroDodge |Parry,#MacroParry } It lets you pick which macro to run. However, [Button1](~Macro1 ) Creates button “Button1”, but can't find the macro. [Button1](#Macro1 )        Creates a broken button that crashes Roll20. So if I want general utility macros invoked from a chat menu, I have to store those as Abilities in a spare character sheet. Example: [Button1](~CharSheetName|Ability1) Creates a button that activates an ability from the specified character sheet. Incidentally, an Ability can make a button to invoke another Ability in the same sheet using just [Button1](~Ability2) , so if you copy and rename a sheet, things won't break. But if I want to skip the button, I must specify the sheet name like %{CharSheetName|Ability2}. Question 1 : Is there a way to also ommit the sheet name, like with the button example above? Using just %{Ability2} wont work here. Question 2 : Instead of specifying the character by name, could I somehow use @{selected} or @{target} here? And are there any other related tricks I missed?
1595968539
Kraynic
Pro
Sheet Author
1 & 2.  The way to omit the sheet name would be to use selected to run that ability from the sheet represented by the selected token: %{selected|Ability2} Since I don't use target for anything, I haven't tried using target for dynamically calling a roll, so I don't know if it works.If it does, be aware that target is usually used for pulling info from a token you don't control (like the armor class to display it by an attack roll for instance), so if it does work, it could allow players to call abilities from characters they shouldn't see. Really, between using selected and the [button](~charactername|abilityname), you can do quite a lot with custom abilities.
So if I'm right you want to run a macro from a button, is that correct?
1595999783

Edited 1595999849
Oosh
Sheet Author
API Scripter
2. {selected} is often used for universal chat menus, so they don't need to be written per-character. {target} can also be used, generally only for the DM as Kraynic said, but works fine. For example (I have no idea what you're playing, but this is from 5e): /w gm [Strength Save](~target|t1|strength_save) That would whisper the gm a button, that could then be clicked, to then click on a token and roll a strength save. That's a lot of clicking, and creating a macro that displays one button to click on one token for one saving throw is a terrible idea, but yes, {target} calls work in Button links.
My idea was for an attack macro to activate the target's defense macro. with a query to pick the type of defense Attack macro: @{selected|token_name} Attacks @{target|token_name} -stuff- ?{WhatDefense?|Dodge,#Dodge |Parry,#Parry } and the Dodge macro is: @{target|token_name} Dodges [[@{target|Dodge}+?{DefenseBonus}-3d6]] But the +?{DefenseBonus} breaks it. I guess you cant stack query within a query then? Even when the first querry should tehnically have already been resolved.
1596045624
GiGs
Pro
Sheet Author
API Scripter
no queries are resolved until all of them are. Look up Order of Operations on the wiki. You can only nest queries by getting familiar with html entities. See here:&nbsp; <a href="https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries" rel="nofollow">https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries</a> And remember, due to order of operations, any macros listed inside a macro have their contents expanded in place before any resolving is done.&nbsp;
Kaspar K. said: Ok, so #macroname calls another macro. Example: A secret roll of d20! #Secret1d20 Runs a macro, including whisper command, etc. Just make sure the #macro is in a seperate line. Inside a Query: ?{WhatDefense?|Dodge,#MacroDodge |Parry,#MacroParry } It lets you pick which macro to run. However, [Button1](~Macro1 ) Creates button “Button1”, but can't find the macro. [Button1](#Macro1 )&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Creates a broken button that crashes Roll20. So if I want general utility macros invoked from a chat menu, I have to store those as Abilities in a spare character sheet. Example: [Button1](~CharSheetName|Ability1) Creates a button that activates an ability from the specified character sheet. Incidentally, an Ability can make a button to invoke another Ability in the same sheet using just [Button1](~Ability2) , so if you copy and rename a sheet, things won't break. But if I want to skip the button, I must specify the sheet name like %{CharSheetName|Ability2}. Question 1 : Is there a way to also ommit the sheet name, like with the button example above? Using just %{Ability2} wont work here. Question 2 : Instead of specifying the character by name, could I somehow use @{selected} or @{target} here? And are there any other related tricks I missed? Try this: [Button 1](! #Macro1)