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 .
×

Queries and Dice Rolls

1657432829

Edited 1657432943
I'm having an issue where I'm trying to make an attack roll and then follow up with a query based on whether the attack hit or not. Dealing with Behirs and want to write a macro instead of just saying out loud that they're swallowed. Example: /r 1d20 + 10 ?{Did the attack hit?|Yes,You take [[3d10+6]] piercing damage and you are Swallowed|No,} Right now, instead of rolling the attack and then asking the query to me, it always ask the query before I can see the dice roll. Meaning I can't select yes or no because I don't know the result of the roll before I make the selection! I'm not trying to compare the rolled value against the AC on a character sheet, I just want to verify with the player whether it hits and then select yes or no in the query drop down. Any thoughts on why this is happening and how to fix it?
1657433515
GiGs
Pro
Sheet Author
API Scripter
Edwin B. said: Right now, instead of rolling the attack and then asking the query to me, it always ask the query before I can see the dice roll. This is something you cannot change. The is an Order of Operations to Roll20 macros - when a macro runs, things don't happen in the order you have the listed in the macro. All queries are collected before the macro really does anything. The only way to do what you want is to have two completely separate macros. Have one macro which rolls theattack, and a second macro to roll the damage. You can include a button in the first macro's output to make it easier. Many systems have an attack roll that prints out a damage buttion with the attack roll, so if you hit you can click the damage button. Lets say you create a macro called Swallow, with the following text: You take [[3d10+6]] piercing damage and you are Swallowed Then your attack roll macro would like like /r 1d20 + 10 [Hit](!&amp;#13;#Swallow) This uses an API Comand Button as described here: <a href="https://wiki.roll20.net/API:Chat#API_Command_Buttons" rel="nofollow">https://wiki.roll20.net/API:Chat#API_Command_Buttons</a>
1657435470

Edited 1657436624
Order of Operations, got it. Unfortunate but makes sense. I tried it your way, which also makes good sense, but I got some weird results. Swallow macro: You take [[3d10+6]] piercing damage and you are Swallowed Macro using #: /roll 1d20 + 10 [Hit](!&amp;#13; #Swallow) I've seen on another forum that someone was having problems calling macros, but it was a bit confusing.&nbsp; I haven't been able to call a macro in another macro on a monster character sheet (NPC) since I started trying.&nbsp; Just keep getting the text rather than actually calling the macro. Macro using %: /roll 1d20 + 10 [Hit](&amp;#13; %{selected|Swallow}) In this case it rolled the 3d10 before I hit the API button and then returned the following: You take Rolling 3d10+6 = (1+5+7)+6'&gt;19 piercing damage and you are swallowed. While you are swallowed you are Blinded and Restrained.
1657436202

Edited 1657436443
GiGs
Pro
Sheet Author
API Scripter
Your photos didn't come through. This is a regular problem with the roll20 forums sadly. I normally host pics on imgur, before adding them to posts here. One thing to be wary of. This &amp;#13; is a HTML Entity, which is a replacement for a line break. When you open a macro, the HTML entity is erased, and replaced with the character it represents. But for this to work, it needs to be a HTML entity, and the button will not work. So when you save a macro containing a html entity, you must not reopen it. If you do reopen it, you'll need to paste that html entity back in.
1657436544
GiGs
Pro
Sheet Author
API Scripter
Edwin B. said: Just keep getting the text rather than actually calling the macro. Do you mean the macro name? If you are just getting the macro name in chat, that means it is not being recognised. Ceck you macro name in both places is spelled exactly the same.
1657436983

Edited 1657437053
Thanks for the help. I actually realized the issue. In API:Chat in the section "Entering API Buttons in Chat" it discusses that you need to use special syntax in order for the attributes to be expanded by the parser. The syntax for '%' is '&amp;#37;'. This let me parse it correctly and I got the intended result. Fixed Macro with % -&gt; &amp;#37;: /roll 1d20 + 10 [Hit](&amp;#13; &amp;#37;{selected|Swallow}) It worked! Thanks for the reply and the idea, I didn't know how to make the API Button and it works great for what I intended. No queries needed. I typed the macros I was using into the first reply I posted to make sure it was recorded.
GiGs said: Edwin B. said: Just keep getting the text rather than actually calling the macro. Do you mean the macro name? If you are just getting the macro name in chat, that means it is not being recognised. Ceck you macro name in both places is spelled exactly the same. Swallow: [[3d10]] damage and swallowed Test Macro: [Hit](&amp;#13; #Swallow) But it's returning "# Swallow" as text.&nbsp; The macro name is the same in each but it's not being called. I've been having this issue other times. Is it an issue if I'm trying to reference a macro in the Attributes and Ability section of that monster?
1657438968
GiGs
Pro
Sheet Author
API Scripter
Abilities on character sheets use the syntax in your first post above (with the &amp;#37;). You only use the syntax I posted for general macros.