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

[Help] Queries in Chat Buttons

August 14 (6 years ago)

Edited August 14 (6 years ago)

I made a chat menu with API commands in the links, some of which contain queries. Except the queries are being triggered when I call the menu to chat, rather than when I click the related button. Besides linking a macro containing the command and query, is there a different way I can write the queries so they aren't prompted until the button is clicked?

Example:

&{template:default} {{descflag= [[1]] }} {{desc= [button](api-command ?{query}) }}
August 14 (5 years ago)

Edited August 14 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

If you replace the ? with its html entity, ? I think (IIRC) it should work properly.

I assume api-command above is a placeholder, and not the actual code?

August 14 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Not really. Queries and attribute calls are run earlier in the order of operations. Any time I need to call a query in a chat menu, I put it into its own Ability, and call the ability in the button:

Chat Menu

&{template:default} {{descflag= [[1]] }} {{desc= [button](~Referenced-Ability) }}


Referenced-Ability

&{template:default} {{descflag= [[1]] }} {{desc= [button](api-command ?{query}) }}


That first code assumes these are abilities on the same sheet, and not a different sheet, or loose macros. For the differences in syntax, look here.

August 14 (5 years ago)

Edited August 14 (5 years ago)

Yes lol it's just a placeholder. I guess either way, I need to use a separate character ability for this (since html gets reverted in collection macros, which is too much of a pain). Thanks for the help, you two!

August 14 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter


keithcurtis said:

Not really. Queries and attribute calls are run earlier in the order of operations. Any time I need to call a query in a chat menu, I put it into its own Ability, and call the ability in the button:

I just tested to make sure my sleep-deprived brain wasn't playing tricks, and the html replacement does work. Using the html replacement means that roll20 doesnt recognise it as the ? character, so doesnt trigger the query. But as it is printed in chat, the text parser runs and converts the html entity into its character (?), and the button will work when clicked.

August 14 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter


Seph said:

Yes lol it's just a placeholder. I guess either way, I need to use a separate character ability for this (since html gets reverted in collection macros, which is too much of a pain). Thanks for the help, you two!

You could always use the Macro Character approach from Keith's stupid tricks thread, set up any macros intended to be universal as Abilities on a separate character for this purpose, and that avoids the html entities being reverted. (And also lets you copy the macros from campaign to campaign easily, using the transmogrifier).



GiGs said:


You could always use the Macro Character approach from Keith's stupid tricks thread, set up any macros intended to be universal as Abilities on a separate character for this purpose, and that avoids the html entities being reverted. (And also lets you copy the macros from campaign to campaign easily, using the transmogrifier).


I probably will for this one, but a lot of my macros are already in collections, and every time I click the edit button on an Ability roll20 freezes for 10 seconds (which adds up for the dozens of macros I have). So I tend to avoid making Abilities; most of those macros will stay in collections ¯\_(ツ)_/¯

August 14 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter


GiGs said:


keithcurtis said:

Not really. Queries and attribute calls are run earlier in the order of operations. Any time I need to call a query in a chat menu, I put it into its own Ability, and call the ability in the button:

I just tested to make sure my sleep-deprived brain wasn't playing tricks, and the html replacement does work. Using the html replacement means that roll20 doesnt recognise it as the ? character, so doesnt trigger the query. But as it is printed in chat, the text parser runs and converts the html entity into its character (?), and the button will work when clicked.


That['s good to know. I'd experiment with that and add it to the Chat Menus entry, but my own brain is rather sleep-deprived.