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 with a Query

I've accomplished to setup queries inside of queries but I'm having a problem inputting a default value, of zero, to a query inside the initial query. This is my current structure (the issue is in bold): ?{Ship check | Driving, [[[[ ?{Additional bonuses} + [[@{skin_primary_equipped}... Full Macro: ?{Ship check | Driving, [[[[?{Additional bonuses} + [[@{skin_primary_equipped} * @{skin_primary_bonus}]] + [[@{skin_secondary_equipped} * @{skin_secondary_bonus}]] + @{driving_dice_pool} + @{dexterity_bonus}]]d10!!dh[[[[?{Additional penalties} + @{skin_primary_equipped} * @{skin_primary_penalty}]] + [[@{skin_secondary_equipped} * @{skin_secondary_penalty}]] + @{dexterity_penalty} + @{blinded} + @{contaminated} + [[round(@{weakened}/3)]]]] + @{driving_modifier}]] | Gunnery, [[[[?{Additional bonuses} + [[@{skin_primary_equipped} * @{skin_primary_bonus}]] + [[@{skin_secondary_equipped} * @{skin_secondary_bonus}]] + @{gunnery_dice_pool} + @{dexterity_bonus}]]d10!!dh[[?{Additional penalties} + [[@{skin_primary_equipped} * @{skin_primary_penalty}]] + [[@{skin_secondary_equipped} * @{skin_secondary_penalty}]] + @{dexterity_penalty} + @{blinded} + @{contaminated} + [[round(@{weakened}/3)]]]] + @{gunnery_modifier}]] | Navigation, [[[[?{Additional bonuses} + [[@{skin_primary_equipped} * @{skin_primary_bonus}]] + [[@{skin_secondary_equipped} * @{skin_secondary_bonus}]] + @{navigation_dice_pool} + @{intelligence_bonus}]]d10!!dh[[?{Additional penalties} + [[@{skin_primary_equipped} * @{skin_primary_penalty}]] + [[@{skin_secondary_equipped} * @{skin_secondary_penalty}]] + @{intelligence_penalty} + @{blinded} + @{contaminated} + [[round(@{weakened}/3)]]]] + @{navigation_modifier}]] | Piloting, [[[[?{Additional bonuses} + [[@{skin_primary_equipped} * @{skin_primary_bonus}]] + [[@{skin_secondary_equipped} * @{skin_secondary_bonus}]] + @{piloting_dice_pool} + @{dexterity_bonus}]]d10!!dh[[?{Additional penalties} + [[@{skin_primary_equipped} * @{skin_primary_penalty}]] + [[@{skin_secondary_equipped} * @{skin_secondary_penalty}]] + @{dexterity_penalty} + @{blinded} + @{contaminated} + [[round(@{weakened}/3)]]]] + @{piloting_modifier}]]}
1570519615

Edited 1570519709
GiGs
Pro
Sheet Author
API Scripter
That's an awful lot of inline brackets? Does the macro work? is the only problem getting the default value of 0 to show? It should just be ?{Additional bonuses|0} 
Ah so that's how it works couldn't figure all that out. It has given the result I wanted and actually helped clarify a segment of the Roll20 documented macro wiki. Thank you :) And yes it all works and believe it or not this is the trimmed down version lol. I'm constantly looking to optimize these macros but that's a different topic.
1570543389

Edited 1570544974
I know this has nothing to do with your answer and mostly my crazy macro but I'm getting this display issue. Should I structure all the other in-query queries the same? The Current Structure: ?{Ship check | Driving, [[[[?{Additional bonuses|0} + [[@{skin_primary_equipped} * @{skin_primary_bonus}]] + [[@{skin_secondary_equipped} * @{skin_secondary_bonus}]] + @{driving_dice_pool} + @{dexterity_bonus}]]d10!!dh[[[[?{Additional penalties|0} + @{skin_primary_equipped} * @{skin_primary_penalty}]] + [[@{skin_secondary_equipped} * @{skin_secondary_penalty}]] + @{dexterity_penalty} + @{blinded} + @{contaminated} + [[round(@{weakened}/3)]]]] + @{driving_modifier}]] | Gunnery, [[[[?{Additional bonuses|0} + [[@{skin_primary_equipped} * @{skin_primary_bonus}]] + [[@{skin_secondary_equipped} * @{skin_secondary_bonus}]] + @{gunnery_dice_pool} + @{dexterity_bonus}]]d10!!dh[[?{Additional penalties|0} + [[@{skin_primary_equipped} * @{skin_primary_penalty}]] + [[@{skin_secondary_equipped} * @{skin_secondary_penalty}]] + @{dexterity_penalty} + @{blinded} + @{contaminated} + [[round(@{weakened}/3)]]]] + @{gunnery_modifier}]] | Navigation, [[[[?{Additional bonuses|0} + [[@{skin_primary_equipped} * @{skin_primary_bonus}]] + [[@{skin_secondary_equipped} * @{skin_secondary_bonus}]] + @{navigation_dice_pool} + @{intelligence_bonus}]]d10!!dh[[?{Additional penalties|0} + [[@{skin_primary_equipped} * @{skin_primary_penalty}]] + [[@{skin_secondary_equipped} * @{skin_secondary_penalty}]] + @{intelligence_penalty} + @{blinded} + @{contaminated} + [[round(@{weakened}/3)]]]] + @{navigation_modifier}]] | Piloting, [[[[?{Additional bonuses|0} + [[@{skin_primary_equipped} * @{skin_primary_bonus}]] + [[@{skin_secondary_equipped} * @{skin_secondary_bonus}]] + @{piloting_dice_pool} + @{dexterity_bonus}]]d10!!dh[[?{Additional penalties|0} + [[@{skin_primary_equipped} * @{skin_primary_penalty}]] + [[@{skin_secondary_equipped} * @{skin_secondary_penalty}]] + @{dexterity_penalty} + @{blinded} + @{contaminated} + [[round(@{weakened}/3)]]]] + @{piloting_modifier}]]
1570546306
GiGs
Pro
Sheet Author
API Scripter
That looks like there's a fault in the macro somewhere. You only get text like that in the popup window when there's an error. It's now traditional at times like these to suggest using a Chat Menu instead of a complex nested query.  If you continue with the nested menu approach, I'd take apart your current one and remove all unneeded brackets (which is most of them), to see if you can eliminate the issue.
1570546550

Edited 1570546748
GiGs
Pro
Sheet Author
API Scripter
For instance, I'd trim down your driving section to this: [[ [[?{Additional bonuses} + (@{skin_primary_equipped} * @{skin_primary_bonus}) + (@{skin_secondary_equipped} * @{skin_secondary_bonus}) + @{driving_dice_pool} + @{dexterity_bonus}]]d10!!dh[[?{Additional penalties} + (@{skin_primary_equipped} * @{skin_primary_penalty}) + (@{skin_secondary_equipped} * @{skin_secondary_penalty}) + @{dexterity_penalty} + @{blinded} + @{contaminated} + round(@{weakened}/3)]] + {driving_modifier}]] There's no need to use inline roll brackets to group related things - they are all going to be hidden by the nested inline brackets anyway. It does occur to me that they are pretty complex calculations. Can you be sure the dh is always less than the number of dice?
1570546751

Edited 1570547694
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
That's happening because you have an incorrect nesting somewhere. From the screencap, it looks like you didn't close an additional bonuses query maybe and so it opens, uses all the roll data until it hits another the second query's bar (|). it looks to me like it's from this section of code: ?{Additional bonuses|0} + [[@{skin_primary_equipped} * @{skin_primary_bonus}]] + [[@{skin_secondary_equipped} * @{skin_secondary_bonus}]] + @{driving_dice_pool} + @{dexterity_bonus}]]d10!!dh[[[[?{Additional penalties|0} However, that all looks properly encoded to me. Honestly, I think you can simplify this a great deal by not putting everything in the query. This is actually best practice when constructing queries; pull everything out that is the same if you can. With some reordering of some of your operations, we can achieve a much simpler macro that should do what your current macro does. How does this work: !?{Ship check | Driving,@{driving_dice_pool} + @{dexterity_bonus}]]d10!!dh[[@{dexterity_penalty} + @{blinded} + @{contaminated} + round(@{weakened}/3) + @{driving_modifier}|Gunnery,@{gunnery_dice_pool} + @{dexterity_bonus}]]d10!!dh[[@{dexterity_penalty} + @{blinded} + @{contaminated} + round(@{weakened}/3) + @{gunnery_modifier}|Navigation,@{navigation_dice_pool} + @{intelligence_bonus}]]d10!!dh[[@{intelligence_penalty} + @{blinded} + @{contaminated} + round(@{weakened}/3) + @{navigation_modifier}|Piloting,@{piloting_dice_pool} + @{dexterity_bonus}]]d10!!dh[[@{dexterity_penalty} + @{blinded} + @{contaminated} + round(@{weakened}/3) + @{piloting_modifier} } [[[[?{Additional Bonuses|0} + @{skin_primary_equipped} * @{skin_primary_bonus} + @{skin_secondary_equipped} * @{skin_secondary_bonus} + @{driving_dice_pool} + ?{Ship check} + @{skin_primary_equipped} * @{skin_primary_penalty} + @{skin_secondary_equipped} * @{skin_secondary_penalty} + ?{Additional penalties|0} ]] ]] The first line is an API command, however it isn't triggering any API script, we are just using the ! to prevent that line of the macro from being output to chat so that the first query that pops up is still which ship check you want to do, even though the ship check options aren't used till the middle of the actual macro. Note that using the api command signal (!) in this way does not require that the game have access to the API or any special subscription level. (EDIT: You can read up on this trick in Ziechael's original post to the stupid tricks thread) The second line is your original equation. I've pulled out a bunch of the nested inline rolls that you were using as parentheses because they aren't needed there; once you're nested beyond the first layer in inline rolls, the only reason to nest further is if it affects the calculation. In this case there should be no effect on the calculation and reducing the nesting of inline rolls will improve the performance of the macro. I've also reordered some of your math to put all the query dependent attribute calls together. This means that the only stuff in the query is this (from the driving option): @{driving_dice_pool} + @{dexterity_bonus}]]d10!!dh[[@{dexterity_penalty} + @{blinded} + @{contaminated} + round(@{weakened}/3) + @{driving_modifier} All of the other calculations used the exact same attribute calls, so we pull them out of the query giving us this section before the use of the ship query: [[[[?{Additional Bonuses|0} + @{skin_primary_equipped} * @{skin_primary_bonus} + @{skin_secondary_equipped} * @{skin_secondary_bonus} + @{driving_dice_pool} + And this section after the ship query: + @{skin_primary_equipped} * @{skin_primary_penalty} + @{skin_secondary_equipped} * @{skin_secondary_penalty} + ?{Additional penalties|0} ]] ]] This way you don't have to worry about html replacements at all. Hope that helps, Scott Edit: sniped by GiGs, and some formatting issues caused by C&P fixed EDIT2: Note that while GiGs replaced your deeply nested inline roll brackets with parentheses, I didn't. This is because the calculations that you had in these were multiplications and so are grouped together and calculated first anyways according to the basic order of mathematical operations (whichever acronym you use).
1570547746

Edited 1570547816
GiGs
Pro
Sheet Author
API Scripter
Yours is a better response :) That's a great suggestion on trimming out the duplicated elements.  regarding the inline rolls: I replaced them with normal parenthesis, which does work to group them properly (I believe!?).
1570547988
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
GiGs said: regarding the inline rolls: I replaced them with normal parenthesis, which does work to group them properly (I believe!?). Oh, definitely, I was just pointing out why I didn't use parentheses, not that the parentheses wouldn't work.
You two have been great ! :D Thanks for the detailed explanation along with the resolution it actually helped me quite a bit to understanding macros and queries. I have gone back and included some optimization. I will definitely be repaying you two for the help once I get this project launched. Anyways thank again.
1570661134
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Glad it helped, and happy to help.