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

Drop Down Query and Formulaic options

Hey all, I've been stumped for most of the day trying to figure out how to do this particular function in a character sheet. However, since the reference is dealing with macros, I thought I'd post here. First off, I've read the Wiki and google-fu'd my way a lot trying to make this problem work, and possibly it's a simple misunderstanding of the way the replacement characters work, however I would like to have a confirmation before I start editing the sheet to that degree. Currently, this is the string that I have: @{MYNAME} rolls SIZE with a modifier of @{MOD} : \n/roll 1d20+?{TN > 20?|Yes, X |No, 0}<[[@{SIZ}+@{MOD}]] So, the way this operates, X is the value that is currently the issue. The macro is intended to provide a drop down prompt to select Yes or No, where No equals 0 and Yes is intended  to equal [[@{SIZ}+@{MOD}-20]]. Note, the reason I suspect this might be a character replacement problem, is because @{MOD} is a variable number which looks like this: <input type="hidden" name="attr_MOD" value="?{Modifier?|0}"> So again, I'm fairly certain this is either impossible without character replacement, or is just incorrect somehow as I am very new to this process. I would appreciate any help that can be provided! Also again, I've reviewed the Wiki among other things for hours now, and either its written and I dont comprehend it, or what I'm trying to do is impossible. Let me know if there is any additional input I missed. Thanks!
If that's exactly how you have it written out, try removing the spaces after the commas in your dropdown section. That should help tremendously. :)
Actually..... Holy crap, I was cropping pictures and preparing a very detailed post as to my exact issue with the drop down box and I realized. What is happening is this: If Yes: It just dawned on me that this is an issue with the secondary query popping up. So I guess my TRUE question is, how can I get a variable number, inside of the same macro/roll, to apply within a drop down query. Sorry for the confusing first post!
1481482221

Edited 1481482324
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Spaces in the roll queries should not cause an issue (at least I've never run into one, unless you're calling global macros in which case they need a space after the macro call) See the wiki on advanced roll query usage for what you need to do to nest queries: <a href="https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries" rel="nofollow">https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries</a>
Scott, Again, maybe I'm an idiot, but I have poured over that wiki and tried many, many different iterations. It is probably my inexperience, but I do not need an additional link to the wiki. What I need, for a relative code dummy like me, is how do I make the @{MOD} attribute remain the same once added in the first place? The obvious option is just to make another button without trying to add a drop down at all. That is my fall back if it is not possible to add a variable number to a formula like this.
1481483744

Edited 1481483925
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, sure. So you aren't going to be able to use the same query for the descriptive text and for the mod in the formula. The query in MOD needs to be ?{Modifier?&#124;0&#125; for the one nested in the query. This won't work for the one out of the query though. EDIT: Actually you could do this though: @{MYNAME} rolls SIZE with a modifier of @{MOD} : \n/roll 1d20+?{TN &gt; 20?|Yes, [[@{SIZ}+?{Modifer?&amp;#125;-20]]|No, 0}&lt;[[@{SIZ}+@{MOD}]] leaving @{Mod} as it is now. I think that will work, but I'm not sure.
Well damn. Thanks. Looks like 2 buttons it is, oh well.
Unless I'm misunderstanding something, I don't see why an advanced Roll Query is needed at all when you can do something like this: /r {1d20 + [[ ?{TN &gt; 20?|No, 0|Yes, 1} * (@{SIZ} + @{MOD} - 20) ]]}&lt;[[ @{SIZ} + @{MOD} ]] or /r {1d20 + [[ {-1, ?{TN|10}}&gt;21 * (@{SIZ} + @{MOD} - 20) ]]}&lt;[[ @{SIZ} + @{MOD} ]]
1481507082
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
also, just realized something. This equation will always give a success in the roll20 dice engine because you are doing {1d20 + @{SIZ} +@{MOD}-20}&lt;[[@{SIZ} +@{MOD}]] This really means you are checking if 1d20 -20 &lt; 0, which since &lt; is actually &lt;= in the dice engine a d20 - 20 is always going to be 0 or less.
Right, that does seem a bit strange... A roll like one of these might make more sense: /r 1d20&lt;[[ {?{TN|@{SIZ}+@{MOD}}, 19}kl1 ]] /r 1d20&gt;[[ {?{TN|@{SIZ}+@{MOD}}, 20}kl1 ]]
1481546355

Edited 1481549133
Right so to clear up some of the confusion, I should probably state the intent of the Macro. This is for the King Arthur Pendragon game system, where the mechanic in the book is "When you add or subtract modifiers, it changes the target number between 1 and 20. If the target number is greater than 20, take the excess and add it to the roll. Any roll greater than 20, is a success." So yes, this does mean you will always succeed in an instance where the TN goes over 20, however KAP is very much about degrees of success. How this is reflected in the current character sheet is simply by adding to the TN, but then you must manually add the excess to the number rolled. This is especially important when dealing with contested rolls, where the "Highest without going over" is the winner.&nbsp; The system itself is pretty archaic in it execution, but all in the name of science. However, I will try some of the other possible solutions and let you guys know, thanks! EDIT/UPDATE: Silvyre comes through again. The first suggestion you made works perfectly and does exactly what I want. It never even occurred to me to use multiplication by 0 and 1. Thanks mate!
1481561858

Edited 1481564331
Ah. You can also use math to add the difference of @{SIZ} + @{MOD} and 20 (if that different is positive) to your roll, replacing a Roll Query: /r {1d20 + [[ {@{SIZ} + @{MOD} - 20, 0}kh1 ]]}&lt;[[ @{SIZ} + @{MOD} ]] I also added some stuff to handle critical successes/fumbles over here , in case you're interested.