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

Problem with API commands and Drop-Down Queries

September 28 (1 year ago)

Edited September 28 (1 year ago)

I'm building a macro that would utilize certain APIs. Supernotes specifically.

Macros for individual commands work perfectly fine, but I'm struggling with creating a universal macro through drop-down. I tried drop-down menu with both full commands and referencing separate macros. 

Universal macro:

?{What's in chat?|
  Info,#Token |
  Notes,#Gm-Notes }

Token macro:

!pcnote --avatar
!pcnote --notitle --charnote


Gm-Notes macro:

!pcnote --token


Both of these work perfectly fine. If, in a universal macro, I choose second option, it also works fine.

But if I choose the first option it seems to combine them in a weird monstrosity:

Thank you in advance.

September 28 (1 year ago)
timmaugh
Forum Champion
API Scripter

You might be running into a problem of the order of operations... namely that macros text is expanded before queries are resolved, so they are expanding into your query. I believe the line break of the token macro is causing you an issue when you choose that option.

An alternative would be to install the MetaScriptToolbox (from the 1-click) and change your macro references into Fetch references:

!?{What's in chat?|
  Info,#(Token) |
  Notes,#(Gm-Notes) }

Since Fetch (a metascript) won't resolve until after the query has resolved, it won't expand the syntax into your command line until you want it to. You sub-macros (Token, and Gm-Notes) wouldn't have to be changed at all.

(There are steps that you would have to do in this situation if one of your included macros wasn't, itself, a call to a mod script... but since at the moment they are both referencing Supernotes, we don't have to take the extra steps. I'm just mentioning it in case later you want to expand this and would encounter that situation.)

September 28 (1 year ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Hi Сертер!

You are almost certainly running into the same issue that everyone does when trying to embed a macro or ability into a drop down query: HTML replacements. Basically, that Macro with the return in it is trying to expand inside the query and breaking the syntax—putting a return into the middle of a query. You can construct such a macro to work within a query, but then it breaks whenever you try to edit or run it on its own. This is a case that is almost certainly better handled by a Chat Menu, and mostly likely, using a Macro Character Sheet, which is generally a good practice for game automation. The links will explain why this is an easier and more efficient solution. Drop down queries are great for simple text or numbers, but very difficult to work with for sub-macros.