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

Questions about Macros - Drop Downs and assigning variables within a macro

Hi, I've spend the better part of two days searching for answers to my questions, and haven't found anything helpful. First Question:  Is there any way to create a query that has multiple drop downs available rather than multiple queries with only one drop down each?  [Example:   Say I have three queries I want answered.  Can I get all three queries displayed in one pop-up rather than three?  That way I can see all my choices in a select-select-select-submit process rather than select-submit-select-submit-select-submit process.] Second Question:  Within a macro, can I assign a variable to a query to use later in the macro to better format the text results and die rolls to the chat?  I would prefer to write the queries, get a label variable and a value variable based on the response to the query, and then use that to format output and my die roll.  [Example:  Query user for a stat, and assign that to VariableStat1 and then pull the value of that stat and assign it to VariableValue1, then do the same for a second query (VariableStat2 and VariableValue2) and then format a print out and die roll of "Character uses VariableStat1 and VariableStat2; Result is (roll (VariableValue1)d6+(VariableValue2)d4)"] I hope my examples clarify my questions, and I suspect the answer to both questions is 'no'. Thanks for your assistance.
1519610915

Edited 1519614236
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hopefully,  this Stupid Trick will answer both questions. Courtesy of the Uncanny Ziechael :)
Looks promising.  I'll have to experiment a bit to see if it does what I need it.   Thanks!
1519621801

Edited 1519622621
Kevin
Plus
I must be aliasing things wrong with this example you provided:   ! ?{Query1} ?{Query2} ?{Query3}/em Player 1 does something...[[ 1d20 + ?{Query3} ]] vs [[ 1d20 - ?{Query2} ]] for [[ 1d8 + ?{Query1} ]] damage! When I change it to look like this: ! ?{Strength,|1|2|3|4|5} ?{Force,|1|2|3|4|5} ?{Bonus,|-2|-1|0|1|2} /em Player 1 does something... [[ 1d20 + ?{Bonus} ]] vs [[ 1d20 - ?{Force} ]] for [[ 1d8 + ?{Strength} ]] damage! I am asked for Strength (select-submit), then Force (select-submit), then Bonus (select-submit), then I am given a text box for Bonus, then a text box for Force, and then a text box for Strength.    The following rolls use the text box answers instead of the ones from the drop down queries. I must have misunderstood, but I thought the second use of the 'query' was supposed to substitute the first use provided in the macro. When I ran this macro:   ! ?{Number of dice}d10 /em Player 1 rolls ?{Number of dice} d11s: [[ ?{Number of dice}d11 ]] That seemed to work as it only asked me for the value once, though I suspect it was supposed to use a random d10 number of d11s rather than an manually inputted number of d11s (I entered 15 for my first test). What am I missing?
1519633395
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Eliminate the commas you have in your first queries. It should read: ! ?{Strength|1|2|3|4|5} ?{Force|1|2|3|4|5} ?{Bonus|-2|-1|0|1|2} /em Player 1 does something... [[ 1d20 + ?{Bonus} ]] vs [[ 1d20 - ?{Force} ]] for [[ 1d8 + ?{Strength} ]] damage! By putting the comma after Strength, it was looking for a variable called "Strength,".
1519757926

Edited 1519764461
Kevin
Plus
Thanks.  That seems to answer my second question.  The first however, is still unanswered.  How to get one pop-up with multiple queries rather then multiple pop-ups with one query each.  Any ideas on that one?  (I'm not very javascript or HTML savvy, so if it was listed in the link you previously provided, I could not parse out the answer). 
1519758967
GiGs
Pro
Sheet Author
API Scripter
Roll20 cant do multiple queries on a single popup. It is a disappointing limitation.
1519759477
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Ah, I don't think that is possible with the Macro syntax. Each query is a popup. It might be possible with the API, but it sounds a bit involved, as I believe you would need to create a form for input.
1519759710
GiGs
Pro
Sheet Author
API Scripter
There's no way to create a popup form with the API either - the closest approximation people have managed is to have a form posted to chat, and the entire form gets reposted to chat every time you click a button on it. It's really not very elegant, and isn't what Kevin is imagining.
KeithCurtis, A third question:  Is it valid to use a variable to reference a statistic on a character sheet?  Does Roll20 perform nested evaluations? Example   ! ?{Attribute|Strength|Dexterity|Constitution} /em rolls ?{Attribute} [[ 1d20 + @{?{Attribute}}]] I cannot seem to make this specifically work. The query works and if I select Dexterity for the character Sam, I am unable to get a nested evaluation that returns the numerical value of the character's dexterity. I get the following output: Sam: ! Dexterity /em rolls Dexterity [[ 1d20 + Sam|Dexterity The only thing that parsed correctly (I think) is that Attribute was assigned the value 'Dexterity'.  I suspect there may be a formatting issue with my query.  If I substitute @{Dexterity} for @{?{Attribute}} I get the appropriate die roll result, but the first two lines still do not work correctly (as I get what is supposed to not print, and the emote doesn't fire correctly). What have I done wrong and misunderstood function wise?
keithcurtis said: Ah, I don't think that is possible with the Macro syntax. Each query is a popup. It might be possible with the API, but it sounds a bit involved, as I believe you would need to create a form for input. G G said: There's no way to create a popup form with the API either - the closest approximation people have managed is to have a form posted to chat, and the entire form gets reposted to chat every time you click a button on it. It's really not very elegant, and isn't what Kevin is imagining. Thanks, KeithCurtis and G G. I suspected that was the case, and I can live with that.
1519765014

Edited 1519765043
Kevin
Plus
Allow me to rephrase my third question..   Instead of nesting evaluations, is there a way to assign values to two variables with one query?   Ex:  If I use ?{Attribute|Strength|Dexterity|Constitution} as my query, which assigns a text value to Attribute, can I also assign AttributeValue the numerical value of Strength, Dexterity or Constitution from the character sheet without asking ?{AttributeValue|Strength,@Strength|Dexterity,@Dexterity|Constitution,@Constitution} as a second query?
Kevin said: A third question:  Is it valid to use a variable to reference a statistic on a character sheet?  Does Roll20 perform nested evaluations? Example   ! ?{Attribute|Strength|Dexterity|Constitution} /em rolls ?{Attribute} [[ 1d20 + @{?{Attribute}}]] This is possible, with a little workaround. First it requires that the character have a custom attribute, I call mine prefix . Set it's value to @{ . You then use this attribute in your macro. Note that the only change is I replaced the @{ with @{prefix}. Due to the order of operations, attribute calls finish before queries. By nesting the attribute prefix ( @{ ) within an attribute itself, you are pushing the attribute call using the query to a later operation. ! ?{Attribute|Strength|Dexterity|Constitution} /em rolls ?{Attribute} [[ 1d20 + @{prefix} ?{Attribute}}]]
1519766982
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thanks Kyle. Kevin was reaching the end of my meager macro skills. :)
keithcurtis said: Thanks Kyle. Kevin was reaching the end of my meager macro skills. :) Thanks  keithcurtis and  Kyle G.
1519769580

Edited 1519774032
Kevin
Plus
Kyle G. said: Kevin said: This is possible, with a little workaround. First it requires that the character have a custom attribute, I call mine prefix . Set it's value to @{ . You then use this attribute in your macro. Note that the only change is I replaced the @{ with @{prefix}. Due to the order of operations, attribute calls finish before queries. By nesting the attribute prefix ( @{ ) within an attribute itself, you are pushing the attribute call using the query to a later operation. ! ?{Attribute|Strength|Dexterity|Constitution} /em rolls ?{Attribute} [[ 1d20 + @{prefix} ?{Attribute}}]] I tried the workaround you suggested.  I get the following response:   TypeError: Cannot read property 'substring' of undefined If I nest a couple of more [[ ]] like this [[ 1d20 + [[@{prefix}?{Attribute}}]] ]] I get the response: No attribute was found for @{Sam|Custom} Is there something else wrong with the macro?  (aside from an extraneous closing bracket } at the end.)
Kevin said: Kyle G. said: Kevin said: This is possible, with a little workaround. First it requires that the character have a custom attribute, I call mine prefix . Set it's value to @{ . You then use this attribute in your macro. Note that the only change is I replaced the @{ with @{prefix}. Due to the order of operations, attribute calls finish before queries. By nesting the attribute prefix ( @{ ) within an attribute itself, you are pushing the attribute call using the query to a later operation. ! ?{Attribute|Strength|Dexterity|Constitution} /em rolls ?{Attribute} [[ 1d20 + @{prefix} ?{Attribute}}]] I tried the workaround you suggested.  I get the following response:   TypeError: Cannot read property 'substring' of undefined If I nest a couple of more [[ ]] like this [[ 1d20 + [[@{prefix}?{Attribute}]] ]] I get the response: No attribute was found for @{Sam|Custom} Is there something else wrong with the macro?  (aside from an extraneous closing bracket } at the end.) Right... I forgot this trick only works if you already know what attribute you want to call. I use it for my GM macros to see things like passive perception
Ahh, So it doesn't apply to a variable in this case, it has to be an actual attribute from the character sheet?  Thanks, Kyle G. That brings back to my alternate question.  Can I use one query to assign values to two variables?
Not really but you could combine the two (value and label) into one value ! ?{Attribute |Strength,[Strength]@{Strength} |Dexterity,[Dexterity]@{Dexterity} |Constitution,[Constitution]@{Constitution} } /em rolls ?{Attribute} [[1d20 + ?{Attribute} ]] This method uses a label on a number so that the label appears when you hover over the number, still allows you to see the stat and combines it all in to one nice query. The other option would be to put the entire roll in the query, which means that you may need to duplicate code /em rolls ?{Attribute |Strength,Strength
[[1d20 + @{Strength} |Dexterity,Dexterity
[[1d20 + @{Dexterity} |Constitution,Constitution
[[1d20 + @{Consitution} }]] or you could simplify further by using /em rolls ?{Attribute |Strength,Strength
[[@{Strength} |Dexterity,Dexterity
[[@{Dexterity} |Constitution,Constitution
[[@{Constitution} } + 1d20]]
Thanks,  Kyle G. I'll give those a shot and see if I can make it work.
1519789634

Edited 1519790689
Kevin
Plus
None of those scripts actually work for me.  The first one asks for me to select that Attribute twice, with the second one being text box rather than a drop down, and uses the value of the second query in the roll.  The other two don't appear to do anything at all. Would it matter if I am using Chrome on a Windows 10 platform?   Or is this functionality that I can only access if I am a PRO ranked user?
No query functionality is usable by all users. Alright, so I have tested the queries and found the problem (was just going based on theory last night, my bad). The problem with the first query thinking that they are two separate queries is due to the first pipe ( | ) being on a separate line. Thus when we we wanting to reuse the query it is under the name AttributeNEW_LINE instead of Attribute. This will fix that (I just move the pipe to the previous line ! ?{Attribute| Strength,[Strength]@{Strength}| Dexterity,[Dexterity]@{Dexterity}| Constitution,[Constitution]@{Constitution} } /em rolls ?{Attribute} [[1d20 + ?{Attribute} ]] And here's the output, so I know it works. Keep in mind that using this process (a label and a value in the query) it displays the modifier in the emote. The other two I am still working on fixing. The theory behind them was to embed a newline character (
) in the query so that it will output the roll on a separate line. Clearly that is not the same in practice.
Thank you for being most patient with me.    ! ?{Attribute| Strength,[Strength]@{Strength}| Dexterity,[Dexterity]@{Dexterity}| Constitution,[Constitution]@{Constitution} } /em rolls ?{Attribute} [[1d20 + ?{Attribute} ]] This suits my intent greatly.  And it expands nicely to adding a ?{Skill|...} query and adding that to the end of the die roll. ! ?{Attribute| Strength,[Strength]@{Strength}| Dexterity,[Dexterity]@{Dexterity}| Stamina,[Stamina]@{Stamina} }  ?{Skill| Academics,[Academics]@[Academics]| Athletics,[Athletics]@{Athletics}| Empathy,[Empathy]@{Empathy} } /em rolls ?{Attribute} + ?{Skill} [[1d20 + ?{Attribute} + ?{Skill} ]] Can you tell me why when I switch things around to make the queries roll a number of dice, I need to put a 0 in front of this to make the roll work appropriately? [[ [[0 + ?{Attribute} +?{Skill} ]]d6]] If ?{Attribute}=4 and ?{Skill} =2, the above statement results in 6d6 being rolled. [[ [[ ?{Attribute} +?{Skill} ]]d6]] The above statement however just results in the value 6 with no dice being rolled. Thanks!
My guess is that it is due to the Label coming before the number in the query value (for example [Strength]@{Strength}). Typically the label is after the value (i.e @{Strength}[Strength]). I have not encountered this before though.
keithcurtis ,  G G , and  Kyle G. ,  Thank you for all your help!!  You have gone above and beyond to answer my questions.