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

Macro Query

1712188420

Edited 1712189269
I would like a macro that when clicked, presents me with a dropdown menu. The drop down menu will be populated with a list of names of other macros I have built and when I pick one of the options, it runs that macro. Is this possible? I saw all the topics on "nested" macros but it seems to only be applicable to abilities and calling rolls. Is this possible and if so can you tell me what and where in this line of code it would be typed? This is just some the test code so I can get an understanding of what the syntax needs to be. This final list will offer at least 10 more options, each calling their own macros. With this example code, the outcome should be that I will execute the macro which will give me a drop down list with one option Blind.   I will then select that option. When I finalize the choice with the submit button, I want it to run the nested macro Pic . What I have does not work and is showing the text Pic in the list so I'm sure my delineation is wrong. I am also getting the text "#Pic" in the chat window Any help is greatly appreciated ?{What Macro Do you want|Blind,#pic}
1712190423

Edited 1712190603
Gauss
Forum Champion
This is possible but incredibly difficult to implement depending on what those macros contain.  When the macro contains a "}" (ending brace) "," (comma) or "|" (pipe) it will break the query and most macros have many braces, commas, and probably some pipes.  The solution to that is to use HTML Substitution to replace those ending braces, commas, and pipes with their HTML entity replacements. However, I notice you are using Collection tab macros, which don't play nice with HTML entities.  This is covered in Roll20 Queries & Nesting . So what is the solution? Don't do what you want, instead use Chat Menus  usually in combination with a Macro Mule instead of Collection tab macros. 
1712204179
timmaugh
Forum Champion
API Scripter
First, your macro is not being detected because it requires a space before the hash: ?{What Macro Do you want|Blind, #pic} That should work to have the #pic macro be detected. However... as Gauss explained, t he problem you run into with Roll20 formations is that macros and abilities are expanded prior to the resolution of the query, so if the expansion introduces new query-control characters (like what Gauss listed), it can change the way the query is parsed... giving you incorrect results and faulty performance. Another solution is to use the Metascript Toolbox, and use Fetch constructions for your macro calls.  The toolbox gets around the above problem because Fetch constructions aren't expanded until after the query resolves. ?{What macro do you want?|Blind, #(pic)|Deaf, #(sound)|Tasteless, #(umami)} Going this route does not require HTML replacements to be made to your original macros. Since you don't have to resort to HTML replacements, your individual macros can run on their own (without having to start as a query choice). If you put the HTML replacement characters into the macro, then it would take the query process to properly convert them into text the macro would recognize. The one thing to deal with is which of your query-chosen macros should hit the chat (like a template message), and which should be sent to a mod script (like sending a command to TokenMod). Here's why... Utilizing the toolbox means turning your initial message into a bangsy message (starting with a bang, "!", and intended for a mod script). This engages the metascripts to do their work. If we need to output the result of our macro to chat, we can dump out of the script operations by inclusion of a {&simple} tag in our command line (effectively turning the message back into a standard, non-script message). So if one of our included macros was just a standard template message that would never normally engage the script deck, and if we chose that from the query and ran it... it would not hit the chat result until we included a {&simple} in the line. We can include a {&simple} in the query in every choice that would require such a dump out to the chat window... however, since that tag has a right-brace and a right-brace would be a control character for the query, we would want to HTML escape it as } Let's say that both the #pic and #sound macros are simple template messages, while the #umami macro is an api call. In that case, we could include the {&simple} tag like this: ?{What macro do you want?|Blind, #(pic) {&simple}|Deaf, #(sound)  {&simple} |Tasteless, #(umami)} That way, if you choose "Tasteless", the #umami macro can run and send its command on to the script deck instead of dumping out to chat. On the other hand, if all of the choices required {&simple}, you can simply put it after the query, on the outside, and not deal with the HTML replacement: ?{What macro do you want?|Blind, #(pic)|Deaf, #(sound)|Tasteless, #(umami)} {&simple}