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

Help with designing a query macro that selects and rolls on a table based on multiple variable inputs?

Hi! I'm new at API Script usage and macro building, and not entirely sure how to label what I'm looking for. I'm trying to build a fishing mini-game for one of my players in which the player can select (variable A) a location to fish and (variable B) the bait to use. The goal is to input these via a query macro with a dropdown menu and have those conditional outputs select and roll on a table of possible catches. Ergo, if they choose to fish at the bridge with worms as bait, or at a river with a lure, those two selections prompt the correct table and roll for a catch under those conditions. It seems the most straightforward (albeit a bit tedious) to create a table for each possible pairing of those variables. I don't know the most efficient way to do bundle all this up, but very happy to learn! Ideally it would be packaged into a single button as the player is not tech savvy. A big part of the purpose here is to make it player-activated with just a few clicks as opposed to verbally telling me and having me verbally reward the outcome. Thanks for any help you can offer, and feel free to sling links my way if there's entry-level tutorials/explanations that seem pertinent!
I found a post that touches on my search here:&nbsp; <a href="https://app.roll20.net/forum/post/5701392/macro-for-variable-rollable-tables" rel="nofollow">https://app.roll20.net/forum/post/5701392/macro-for-variable-rollable-tables</a> It looks simple enough for one variable as Scott C. has listed in that post, but can it be done for two variables?&nbsp;
1588529631

Edited 1588529653
GiGs
Pro
Sheet Author
API Scripter
Is the second variable conditional on the first? That is, is the list of baits always the same, or does it vary depending on what location you chose? If its a fixed list, yes, you can do this. You'll want to use a Query for both, like so ?{select location|London|Aberdeen|Cheshire} If the second list changes what is displayed based on location, it is trickier but still can be done. In this version the best way is to create a separate macro for each bat table, then use a chat menu to select which one. We can describe that in more detail if its needed.
Hi GiGs,&nbsp; Thanks for responding! I figured I'd create a table for each combination of location + bait, so it wouldn't be limited by one type constraining the next, but rather me creating a new table for new baits in the same location. The list of baits will be static (but grows as the game progresses) as will the list of locations. I've also looked into The Aaron's Recursive Tables notes (and uploaded the awesome script) to roll the desired results from the current macro&nbsp; !rt[showicons] [[2t[Fish-SMRiv-Lug] ]] To quickly rig the table, I named it such as "Fishing" (activity) "Saltmarsh River" (Location) "Lugworm" (bait). That's totally arbitrary. Ideally I'd be able to create one macro for Fishing that queries a location and a bait and the recursively rolls on a table based on those two variables. I adore the show icon feature, especially with labels as presented there. If I can wrap that into one button (having created the tables in advance), that's the goal. I hope the roll can be done by players and public for all to see. A thousand blessings again!
1588547476
GiGs
Pro
Sheet Author
API Scripter
You can roll on a table whose name is a compound of two (or more!) queries, like /roll 1t[Fishing-?{location?|Saltmarsh}-?{Bait?|Lugworm}] If you oick the first option in each dropdown, this should roll on a table named Fishing-Saltmarsh-Lugworm. If your table names are and queries are built appropriately, this should do what you need?
Hey GiGs, Thanks! This should be what I need. I'll work out the kinks and give a shout if anything else comes up, but I think you've got me covered here. Big ups for the help. Much appreciated.
1588638246
GiGs
Pro
Sheet Author
API Scripter
You're welcome :)