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 .
×
Advertisement Create a free account

Yes/No query help

1627419162
Hello, I am new to macro building and would appreciate some help with a Yes No query in my macro. I would like the macro to continue to the next query after selecting Yes and complete after selecting No. Many thanks, Sam ?{ Light/Vision options: |Fireflies (dim5), !token-mod --set emits_bright_light#off emits_low_light#on bright_light_distance#0 low_light_distance#5 |Candle (br5/dim10), !token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#5 low_light_distance#5 |Dancing Lights (dim10), !token-mod --set emits_bright_light#off emits_low_light#on bright_light_distance#0 low_light_distance#10 |Lamp (br15/dim45), !token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#15 low_light_distance#30 |Lightsword (br15/dim30), !token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#15 low_light_distance#15 |Torch/Light Cantrip (br20/dim40), !token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#20 low_light_distance#20 |Hooded Lantern (br30/dim60), !token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#30 low_light_distance#30 |Bullseye Lantern (br40/dim80), !token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#40 low_light_distance#40 |Create Bonfire (br40/dim80), !token-mod --set emits_bright_light#on emits_low_light#on bright_light_distance#40 low_light_distance#40 |Lighting off, !token-mod --on has_bright_light_vision emits_bright_light emits_low_light --set bright_light_distance#0 low_light_distance#0 |Normal vision, !token-mod --on has_bright_light_vision emits_bright_light emits_low_light --set bright_light_distance#0 low_light_distance#0 |Darkvision on, !token-mod --set has_bright_light_vision#on has_night_vision#on night_vision_distance#60 night_vision_effect#nocturnal |Superior Darkvision on, !token-mod --set has_bright_light_vision#on has_night_vision#on night_vision_distance#120 night_vision_effect#nocturnal |Darkvision off, !token-mod --set has_bright_light_vision#on has_night_vision#off |Blinded, !token-mod --set has_bright_light_vision#off has_night_vision#off defaulttoken } ?{Select Colour?|Yes,|No,} !token-mod ?{Colour|Black, --set lightColor#000000|Silver, --set lightColor#c0c0c0|Gray, --set lightColor#808080|White, --set lightColor#ffffff|Maroon, --set lightColor#800000|Red, --set lightColor#ff0000|Purple, --set lightColor#800080|Fuchsia, --set lightColor#9900ff|Pink, --set lightColor#ffc0cb|Green, --set lightColor#008000|Lime, --set lightColor#00ff00|Olive, --set lightColor#808000|Yellow, --set lightColor#ffff00|Navy, --set lightColor#000080|Blue, --set lightColor#0000ff|Teal, --set lightColor#008080|Aqua, --set lightColor#00ffff|Orange, --set lightColor#ffa500|-, |Aquamarine, --set lightColor#7fffd4|Coral, --set lightColor#ff7f50|Cornflowerblue, --set lightColor#6495ed|Crimson, --set lightColor#dc143c|Darkcyan, --set lightColor#008b8b|Darkgreen, --set lightColor#006400|Darkseagreen, --set lightColor#8fbc8f|Deeppink, --set lightColor#ff1493|Firebrick, --set lightColor#b22222|Gold, --set lightColor#ffd700|Goldenrod, --set lightColor#daa520|Lavender, --set lightColor#e6e6fa|Orangered, --set lightColor#ff4500|Rebeccapurple, --set lightColor#663399|Saddlebrown, --set lightColor#8b4513|Salmon, --set lightColor#fa8072|Seagreen, --set lightColor#2e8b57|Skyblue, --set lightColor#87ceeb|Snow, --set lightColor#fffafa|Violet, --set lightColor#ee82ee|Wheat, --set lightColor#f5deb3|Whitesmoke, --set lightColor#f5f5f5|-, |None, --set lightColor#transparent}
1627424589
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
You'll need to nest the other queries in the yes option of the query. Currently this requires you to html escape the problem characters of the nested content .
1627426404
timmaugh
Pro
API Scripter
Or you can use APILogic to make that part of the line included/excluded on a conditional basis.
1627463419
Thanks for the responses, I’ll check those out.
1627481801
timmaugh said: Or you can use APILogic to make that part of the line included/excluded on a conditional basis. Hey, I've added the APILogic and libInline scripts and messed around with the syntax, but I am more confused than anything else. I attempted to use this conditional statement with yes and no, but I haven't managed to make it function yet. Does the 'yes' and 'no' go in the '(conditions)' sections? Would I still start with ?{Select Colour?| Any help would be greatly appreciated. {& if (conditions) } true text {& elseif (conditions) } alt text {& else } default text {& end}
1627502035

Edited 1627502120
timmaugh
Pro
API Scripter
So, to be clear, APILogic won't help you avoid a second query based on your answer to the first query. The only way to accomplish that is to nest the second query like Scott mentioned. However, in this case, APILogic can help with just a single query: !{&if None = ?{Select Colour?|None| Aqua,00ffff|Aquamarine,7fffd4|Black,000000|Blue,0000ff|Coral,ff7f50|Cornflowerblue,6495ed|Crimson,dc143c|Darkcyan,008b8b|Darkgreen,006400|Darkseagreen,8fbc8f|Deeppink,ff1493|Firebrick,b22222|Fuchsia,9900ff|Gold,ffd700|Goldenrod,daa520|Gray,808080|Green,008000|Lavender,e6e6fa|Lime,00ff00|Maroon,800000|Navy,000080|None,transparent|Olive,808000|Orange,ffa500|Orangered,ff4500|Pink,ffc0cb|Purple,800080|Rebeccapurple,663399|Red,ff0000|Saddlebrown,8b4513|Salmon,fa8072|Seagreen,2e8b57|Silver,c0c0c0|Skyblue,87ceeb|Snow,fffafa|Teal,008080|Violet,ee82ee|Wheat,f5deb3|White,ffffff|Whitesmoke,f5f5f5|Yellow,ffff00} } {&else}token-mod --set lightColor#?{Select Colour?}{&end} APILogic helps in a few ways, here. First, it lets you handle two queries at once. If you don't want to pick the color, just pick "None" from the list. APIL is testing for that value to return an empty command line: !{&if None=<result of query>} {&else}... The "None" will never make it to the token-mod call. In other words, you don't have to have only HTML colors in the list for the second query; the two queries can be merged. Second, doing things this way means that you don't have to recreate a bunch of typing to put the same token-mod line into each option of the query. Not only does that save on typing, but if you have to change the line later, you don't have to change it 20 or 30 times. Third, not that it comes into play on this particular command line, but by separating the api command line (the token-mod call) from the query you save yourself having to escape the characters (commas, pipes, right-braces) that could break your query. That saves you the effort of having to do the character substitutions, and it leaves your eventual command line much more readable.
1627535292

Edited 1627535398
Thank you for the thorough explanation. I am completely new to coding so that helped a lot.