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

Query before a query macro?

Trying to create a Witcher sheet for the recently released TRPG to play with my friends. My HTML is rather scratchy (I'm not the worst, been teaching myself so far :D).  With a ranged shot the player gets to select a body part they are aiming for, and i've managed to get a macro working for that successfully (including modifiers for each and linking to the correct sheet skills) below:  ?{Archery| Head, **Archery** You attempt a ranged attack toward the *Head* with [[1d10+@{dex}+@{archery}-6]]. | Torso, **Archery** You attempt a ranged attack toward the *Torso* with [[1d10+@{dex}+@{archery}-1]]. | Arm/Limb, **Archery** You attempt a ranged attack toward an *Arm* or *Limb* with [[1d10+@{dex}+@{archery}-3]]. | Leg/Special, **Archery** You attempt a strong ranged attack toward a *Leg* or *Special* area with [[1d10+@{dex}+@{archery}-2]]. } My issue is I want to be able to let the player choose their range modifier before or after this query toward their overall roll (+5 for Point Blank, +0 for close, -2 for medium, -4 for long and -6 for extreme range) but I have no idea how to include that. I saw a wiki on ' Advanced Roll Queries' but I got a bit dizzy getting my head around it. Any insight out there for a bit of a beginner? Thanks a bunch guys. 
1536290105

Edited 1536290127
GiGs
Pro
Sheet Author
API Scripter
There's a witcher sheet already in development, there's a thread here somewhere. Regarding your macro, I think this should work !?{Range to Target|Point Blank,+5|Close,+0|Medium,-2|Long,-4|Extreme,-6} ?{Archery| Head, **Archery** You attempt a ranged attack at ?{Range to Target }  toward the *Head* with [[1d10+@{dex}+@{archery}-6 ?{Range to Target } ]]. | Torso, **Archery** You attempt a ranged attack at ?{Range to Target }  toward the *Torso* with [[1d10+@{dex}+@{archery}-1?{Range to Target } ]]. | Arm/Limb, **Archery** You attempt a ranged attack at ?{Range to Target }  toward an *Arm* or *Limb* with [[1d10+@{dex}+@{archery}-3?{Range to Target } ]]. | Leg/Special, **Archery** You attempt a strong ranged attack at ?{Range to Target }  toward a *Leg* or *Special* area with [[1d10+@{dex}+@{archery}-2?{Range to Target } ]]. } The ! on the first line means that output wont appear in chat. But the result can be used in the rest of the macro. Inside the query, the ending } needs to be replaced with }
1536292360

Edited 1536292458
Leothedino
Sheet Author
Thanks GG! And I didn't know, I will have to check it out and show some support for the sheet.  Really appreciate you also highlighting where the replacement characters work, helps me learn more. Will get onto this ASAP. EDIT: AHHH works perfectly, so happy -and- I understand how now. Cheers mate, serious kudos!
1536299516
Andreas J.
Forum Champion
Sheet Author
Translator
CPP is working on the sheet
1536455947

Edited 1536456767
Leothedino
Sheet Author
G G said: There's a witcher sheet already in development, there's a thread here somewhere. Regarding your macro, I think this should work !?{Range to Target|Point Blank,+5|Close,+0|Medium,-2|Long,-4|Extreme,-6} ?{Archery| Head, **Archery** You attempt a ranged attack at ?{Range to Target }  toward the *Head* with [[1d10+@{dex}+@{archery}-6 ?{Range to Target } ]]. | Torso, **Archery** You attempt a ranged attack at ?{Range to Target }  toward the *Torso* with [[1d10+@{dex}+@{archery}-1?{Range to Target } ]]. | Arm/Limb, **Archery** You attempt a ranged attack at ?{Range to Target }  toward an *Arm* or *Limb* with [[1d10+@{dex}+@{archery}-3?{Range to Target } ]]. | Leg/Special, **Archery** You attempt a strong ranged attack at ?{Range to Target }  toward a *Leg* or *Special* area with [[1d10+@{dex}+@{archery}-2?{Range to Target } ]]. } The ! on the first line means that output wont appear in chat. But the result can be used in the rest of the macro. Inside the query, the ending } needs to be replaced with } A puzzle I am trying to work out now, I tried to take that macro and embed it as HTML into my custom sheet. I had thought I got the hang of it, and didn't want to bother any of you thinking it would 'click in place' eventually in my head. Turns out, it's not. Here's what I have:  <label>Archery</label><strong class='dee'></strong><input type="number" name='attr_archery' class='sheet-short'><button type='roll' name='roll_archery' value='?{Range to Target|Point Blank,+5|Close,+0|Medium,-2|Long,-4|Extreme,-6} Head, **Archery** You attempt a ranged attack at ?{Range to Target} toward the *Head* with [[1d10+@{dex}+@{archery}-6?{Range to Target}]]. | Torso, **Archery** You attempt a ranged attack at ?{Range to Target} toward the *Torso* with [[1d10+@{dex}+@{archery}-1?{Range to Target}]]. | Arm/Limb, **Archery** You attempt a ranged attack at ?{Range to Target} toward an *Arm* or *Limb* with [[1d10+@{dex}+@{archery}-3?{Range to Target}]]. | Leg/Special, **Archery** You attempt a strong ranged attack at ?{Range to Target} toward a *Leg* or *Special* area with [[1d10+@{dex}+@{archery}-2?{Range to Target}]]. }'></button><br /> Do I need to replace the } after each 'dex' and 'archery' call? I thought they might be protected inside the [[ ]]? Sorry if this is coming across dumb, I feel like this pattern or method is on the tip of my tongue and i'm just over-thinking it? Additionally, I gave it a go by using replacement for all of (what I thought) were offending characters in-between the opening and end brackets (see code below), this also failed...  <label>Archery</label><strong class='dee'></strong><input type="number" name='attr_archery1' class='sheet-short'><input type="number" name='attr_archery' class='sheet-short'><button type='roll' name='roll_archery' value='?{Range to Target|Point Blank,+5|Close,+0|Medium,-2|Long,-4|Extreme,-6} Head, **Archery** You attempt a ranged attack at ?{Range to Target} toward the *Head* with [[1d10+@{dex|+@{archery|-6?{Range to Target}]]. | Torso, **Archery** You attempt a ranged attack at ?{Range to Target} toward the *Torso* with [[1d10+@{dex|+@{archery|-1?{Range to Target}]]. | Arm/Limb, **Archery** You attempt a ranged attack at ?{Range to Target} toward an *Arm* or *Limb* with [[1d10+@{dex|+@{archery|-3?{Range to Target}]]. | Leg/Special, **Archery** You attempt a strong ranged attack at ?{Range to Target} toward a *Leg* or *Special* area with [[1d10+@{dex|+@{archery|-2?{Range to Target}]]. }'></button><br /> Edit: Spelling mistake. 
1536457503

Edited 1536457694
GiGs
Pro
Sheet Author
API Scripter
One thing you never do is replace any characters in attribute calls. So dex and archery should be unchanged from @{dex} and @{archery}. You seem to have mangled the button code. Your code is ?{Range to Target|Point Blank,+5|Close,+0|Medium,-2|Long,-4|Extreme,-6} Head, **Archery** You attempt a ranged attack at ?{Range to Target} toward the *Head* with [[1d10+@{dex}+@{archery}-6?{Range to Target}]]. | Torso, **Archery** You attempt a ranged attack at ?{Range to Target} toward the *Torso* with [[1d10+@{dex}+@{archery}-1?{Range to Target}]]. | Arm/Limb, **Archery** You attempt a ranged attack at ?{Range to Target} toward an *Arm* or *Limb* with [[1d10+@{dex}+@{archery}-3?{Range to Target}]]. | Leg/Special, **Archery** You attempt a strong ranged attack at ?{Range to Target} toward a *Leg* or *Special* area with [[1d10+@{dex}+@{archery}-2?{Range to Target}]]. }' The macro i suggested would be '!?{Range to Target|Point Blank,+5|Close,+0|Medium,-2|Long,-4|Extreme,-6} ?{Archery| Head, **Archery** You attempt a ranged attack at ?{Range to Target }  toward the *Head* with [[1d10+@{dex}+@{archery}-6 ?{Range to Target } ]]. | Torso, **Archery** You attempt a ranged attack at ?{Range to Target }  toward the *Torso* with [[1d10+@{dex}+@{archery}-1?{Range to Target } ]]. | Arm/Limb, **Archery** You attempt a ranged attack at ?{Range to Target }  toward an *Arm* or *Limb* with [[1d10+@{dex}+@{archery}-3?{Range to Target } ]]. | Leg/Special, **Archery** You attempt a strong ranged attack at ?{Range to Target }  toward a *Leg* or *Special* area with [[1d10+@{dex}+@{archery}-2?{Range to Target } ]].}' Note: not sure why my code is breaking across lines like that. Another chat glitch maybe.
Your code doesn't work in my sheet. Originally to test it out I made it as an ability in the back of the sheet and that worked, but the moment I took it and placed it in as HTML itself, the first box (range) performed but the second failed. So I was just trying to make some sense of why it worked as an ability, but failed when written into the sheet. I am sure something will 'snap into place' eventually, mistakes give way for experience. Thanks anyway.
1536478197
GiGs
Pro
Sheet Author
API Scripter
I'm not sure why it doesnt work in the sheet, I'm sure I'm overlooking something that might come to me later. Edit: aha, it probably needs an end of line character. put \n at the end of the first line (and only the first line). The reason yours isnt working, is it isn't properly formed code. Look at the first two lines value='?{Range to Target|Point Blank,+5|Close,+0|Medium,-2|Long,-4|Extreme,-6} Head, **Archery** You attempt a ranged attack at ?{Range to Target} toward the *Head* with [[1d10+@{dex}+@{archery}-6?{Range to Target}]]. | You have a {range to target} query, but you end it improperly and then have a the locations query but don't start it properly. 
<button type='roll' name='roll_archery' value='!?{Range to Target|Point Blank,+5|Close,+0|Medium,-2|Long,-4|Extreme,-6} ?{Archery| Head, **Archery** You attempt a ranged attack at ?{Range to Target} toward the *Head* with [[1d10+@{dex}+@{archery}-6?{Range to Target}]]. | Torso, **Archery** You attempt a ranged attack at ?{Range to Target} toward the *Torso* with [[1d10+@{dex}+@{archery}-1?{Range to Target}]]. | Arm/Limb, **Archery** You attempt a ranged attack at ?{Range to Target} toward an *Arm* or *Limb* with [[1d10+@{dex}+@{archery}-3?{Range to Target}]]. | Leg/Special, **Archery** You attempt a strong ranged attack at ?{Range to Target} toward a *Leg* or *Special* area with [[1d10+@{dex}+@{archery}-2?{Range to Target}]]. }'></button> The above code, which (unless I have foolish put on the wrong lines, maybe?) is the one you helped me on, this is -exactly- as it is in the HTML section of the sheet. First box comes up, second (as shown in the picture) makes the error box. Was there supposed to be something linking the Range to Target and Archery List Query inbetween that I missed? Or perhaps you cannot nest a query like this on a roll button?
1536490262
GiGs
Pro
Sheet Author
API Scripter
I suggested putting an \n at the end of the first line. In macros, you can press enter to get a new line. In html, that doesnt work, you need to enter a special character combination to get the new line. So the code should be (but I havent dont this in html before, so I'm just guessing): <button type='roll' name='roll_archery' value='!?{Range to Target|Point Blank,+5|Close,+0|Medium,-2|Long,-4|Extreme,-6} \n ?{Archery| Head, **Archery** You attempt a ranged attack at ?{Range to Target} toward the *Head* with [[1d10+@{dex}+@{archery}-6?{Range to Target}]]. | Torso, **Archery** You attempt a ranged attack at ?{Range to Target} toward the *Torso* with [[1d10+@{dex}+@{archery}-1?{Range to Target}]]. | Arm/Limb, **Archery** You attempt a ranged attack at ?{Range to Target} toward an *Arm* or *Limb* with [[1d10+@{dex}+@{archery}-3?{Range to Target}]]. | Leg/Special, **Archery** You attempt a strong ranged attack at ?{Range to Target} toward a *Leg* or *Special* area with [[1d10+@{dex}+@{archery}-2?{Range to Target}]]. }'></button>
1536494161

Edited 1536494177
Leothedino
Sheet Author
Cheers man, thanks for the patience mate. 
1536504246

Edited 1536504412
Leothedino
Sheet Author
I worked it out, finally! I have no idea if this would be useful to somebody that comes across this thread who had issues like I did, but you never know. In short, I realised I was over complicating things. Instead of trying to make a drop down option with multiple outcomes, each having its own sprawl of commands, I made one and just queried the process along the way. I still have no idea how or even if you can get the query labels to work like 'calls' in the sentence (e.g. The Archer makes a *close* ranged *fast* shot at the targets *torso* for X damage.') but damn, so elated to settle for this at the moment!    <button type='roll' name='roll_archery' value='@{character_name} makes a ranged ***Archery*** attack at their target for [[1d10+@{dex}+@{archery}?{Range to Target?|Point Blank,+5|Close,+0|Medium,-2|Long,-4|Extreme,-6}?{Attack Type?|Fast,+0|Strong,-3|}{Body Part?|Head,-6|Torso,-1|Arm,-2|Leg,-2}]]'></button> For any complete beginners like me, here is what it does: The outcome is a button that when pressed opens three query boxes, the first asking for the 'range' of the attack, the second asks if it is a 'strong or fast attack'  and the final one asks for the 'body part' the attack is aiming for. Calculating these modifiers along with the character sheets 'Dexterity' and 'Archery' stat, it gives the outcome as a combined score.