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

The new D&D 2024 sheet is now available!

Create a free account

Need help with a query and tables in a macro

I've run into a mind-block in what elements of building a roll need to be added in what order to do a simple/complex thing.  It's probably easy, but I'm just not seeing it.  Your help is appreciated.  Situation: I'm using Roll20 to Solo play/build some scenarios and old modules.  One of the mechanics uses a simple query that is modified.  I've got 2 tables that I want to make into a single macro that asks the Likeness of the outcome, rolls, and returns the answer preferably also giving the d20 roll. My first table Likeliness  -->  Modifier Impossible  -->   -6 Highly Unlikely  -->   -4 Unlikely  -->   -2 Possible  -->   0 Likely  -->   +2 Highly Likely  -->   +4 A Certainty  -->   +6 My second table (The Q/A table) d20 --> Result 1-6 --> No 7-12 --> Maybe 13-20 --> Yes
1604085594
GiGs
Pro
Sheet Author
API Scripter
You cant do this without an API script, or using lots of separate rollable tables (a separate table for each different modifier). If you are willing to represent the Q/A table results as numbers, not text, it can be done.  The actual roll can be done as  /roll 1d20+?{Likeliness?| Impossible,-6| Highly Unlikely,-4| Unlikely,-2| Possible,0| Likely,2| Highly Likely,4| A Certainty,6} You can show the roll, the modifier, and the total separately using a rolltemplate and the Reusing Rolls trick (see wiki): &{template:default} [[ [[1d20]]+[[?{Likeliness?| Impossible,-6| Highly Unlikely,-4| Unlikely,-2| Possible,0| Likely,2| Highly Likely,4| A Certainty,6}]] ]] {{Modifier=$[[1]]}} {{Roll=$[[0]]}} {{Total=$[[2]]}} And to show the output as a number, 1 for No, 2 for Maybe, 3 for Yes, you can do this more convoluted roll: &{template:default} [[{1, [[ {3,ceil(([[1d20]]+[[?{Likeliness?| Impossible,-6| Highly Unlikely,-4| Unlikely,-2| Possible,0| Likely,2| Highly Likely,4| A Certainty,6}]]+1)/6)}kl1 ]]}kh1]] {{Modifier=$[[1]]}} {{Roll=$[[0]]}} {{Result=$[[3]]}} This will give a result of 1, 2, or 3. It might be possible to use the table-name trick to make do with 3 rollable tables, each with a single  item (No, Maybe, Yes), named something like result-1, result-2, and result-3, but I couldnt get the syntax to work.
OK.  I followed that the first example would make the query and the d20 roll, and do the math.  In the 2nd and 3rd example I lost the plot on how that result would generate 1, 2, or 3 using the weighting on the Q/A table. So, the only way I'm seeing atm is that I would have to do the math on weighting the Q/A table based on likeliness for each and then build 7 different tables.  Create a macro that queries asking on which table to roll, returning the result from the appropriate table.   My list of tables is going to get really long really fast...  There's nothing elegant?
1604119256
GiGs
Pro
Sheet Author
API Scripter
KingsTears said: So, the only way I'm seeing atm is that I would have to do the math on weighting the Q/A table based on likeliness for each and then build 7 different tables.  Create a macro that queries asking on which table to roll, returning the result from the appropriate table.   My list of tables is going to get really long really fast...  There's nothing elegant? That's the way to do it without an API script. There's an old script called (I think) RealRollable Tables that lets you roll on a table with modifiers. KingsTears said: OK.  I followed that the first example would make the query and the d20 roll, and do the math.  In the 2nd and 3rd example I lost the plot on how that result would generate 1, 2, or 3 using the weighting on the Q/A table. Did you past the code into a campaign and see what happened? If you see the output it'll be clearer what they are each doing. The second one only shows the final roll, along with the original d20, which you can then compare to a table. It's only the final one that results in a 1, 2, or 3. Referring to the wiki page on Reusing Rolls explains how the technique of getting different parts of a roll and displaying them separately works. The actual process of getting the result to 1, 2, or 3 also requires divining the roll by 6, rounding up, and ensuring the result cannot be below 1 or greater than 3. The code for that is convoluted in roll20 :)