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

Can I use api commands inside a roll query?

November 16 (3 years ago)

I want to have a macro button in my bar, which opens a roll query popup, which will execute a different api command depending on which option I selected. I've tried the straightforward way, but when I do this it will send the api command to chat, but not execute it. This is what I've tried:

?{Target|Map1, !mc move --target Map1|Map2, !mc move --target Map2|rejoin, !mc rejoin}

I've also tried putting the command in seperate macros and calling those, but this also sends the command to chat without executing it.

November 16 (3 years ago)

Edited November 16 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Hi caluthan!

Remove those spaces before the API call. An API call begins with an exclamation point. Instead of receiving this:

!mc move --target Map2

chat is receiving this:

 !mc move --target Map2


Try this code:

?{Target|Map1,!mc move --target Map1|Map2,!mc move --target Map2|rejoin,!mc rejoin}


November 16 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Also, if any API calls have pipes in them, be sure to replace that pipe character with the HTML equivalent: |

The order of operations can play havoc with queries. You can find more info here.

Here's a sample of a simple tokenmod re-sizing query with replacements in place:

?{size|M,!token-mod --set width|70 height|70|L,!token-mod --set width|140 height|140}


In many cases, it's much simpler to build a Chat Menu.

November 16 (3 years ago)

Thx this worked. :D