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

Nesting Queries and selecting Attributes from queries?

June 15 (8 years ago)

Edited June 15 (8 years ago)
Ok, this is a two parter.

1st Question: (This one got solved already, thank you Ziechael and Scott C.)
I'm trying to build the following. First I get a query that opens a dropdown menu with "Strength" and "Dexterity" as well as "Other Stat".
If I select Strength or Dexterity it picks the values from @Strength etc. So far that's easy.
When I pick "Other Stat" it should open a second query that now lists all stats, so I can pick from there.
I tried the following:
?{Ability?|Strength,@{Strength}|Dexterity,@{Dexterity} | Other Stat, ?{Other Stat|Stamina,@{Stamina} | Charisma,@{Charisma} |Manipulation,@{Manipulation} | Appearance,@{Appearance} }}

Unfortunately all I get is a list that looks like this then:


If I select "Other Stat" it gives me a normal text-input query.
Obviously not what I want.

Somehow the outer query snatches up the values of the inner query.

Is there any way to do what I want it to do?

2nd Question:
Is there any way to reference the "name" of a query like above.
Again, here's what I'm trying to do. When you select "Dexterity" from the above dropdown menu, it should then use it in the default template and print:



And obviously replace Dexterity with "Strength" if selecting Strength and so on.

Unfortunately so far I only ever managed to either get the name of the attribute or the value back, no way to get both.

I also tried the following:

@{?{Which Attribute?|Strength|Dexterity}}

hoping it would call @{Strength} or @{Dexterity} respectively, but that only results in an interesting error message.

Any idea how to pull this one off?

June 15 (8 years ago)
Ziechael
Forum Champion
Sheet Author
API Scripter
Check out the wiki for details on nested queries... in the meantime:
?{Ability?|Strength,@{Strength}|Dexterity,@{Dexterity} | Other Stat, ?{Other Stat|Stamina,@{Stamina}|Charisma,@{Charisma}|Manipulation,@{Manipulation}|Appearance,@{Appearance}}}
June 15 (8 years ago)
Ziechael
Forum Champion
Sheet Author
API Scripter
As for nesting queries within an attribute call... it can be done but is a bit fiddly, let us know if you want to explore that option and those secrets will also be revealed to you ;)
Oh, thank you so much!

i had checked that page (I swear!) But for some reason I read right past that section.

I have to see if my second problem can be solved with the same solution
June 15 (8 years ago)

Edited June 15 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
On my phone, so can't do the full instructional on this, but read through the advanced roll query section of the wiki. That will take care of number 1.

You can't reference the name of a roll query, but you could just put that whole field in the option:

&{template:default} {{name=Skillroll}} {{?{Ability?|Strength,Strength=@{Strength}|Dexterity,Dexterity=@{Dexterity}} }}

Edit: Beyond ninja'd by Ziechael ;)
June 15 (8 years ago)

Edited June 15 (8 years ago)
Thank you as well Scott, #1 is indeed solved easily with that. Somehow I totally missed that.

Well, yes I could do that, but I actually want to do some math with @Dexterity and so later on too, so unfortunately that's not a solution.

Ziechael said:
As for nesting queries within an attribute call... it can be done but is a bit fiddly, let us know if you want to explore that option and those secrets will also be revealed to you ;)
Ok, just escaping some characters doesn't seem to do the trick. Due to order of operations, it seems the query is resolved after the attribute call, so it doesn't do anything then.
Could you point me in the right direction, for where to look for the answers?

June 15 (8 years ago)
Ziechael
Forum Champion
Sheet Author
API Scripter
Avert yon eyes those not ready for the secrets of the multiverse!

Those who are ready however should check out this thread where I semi-coherently attempt to convey how to dynamically call attributes using queries :)
June 15 (8 years ago)

Edited June 15 (8 years ago)
I think I might be onto a solution myself now, that's not perfect but will work for my purposes... have to make more tests.

But I will check out your link now, maybe you have come up with something better. (that I understand :) )
June 15 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
@Ziechael

That won't work for queries though will it?

@Quatar
Quatar said:
Well, yes I could do that, but I actually want to do some math with @Dexterity and so later on too, so unfortunately that's not a solution.
Yep, so you'd put all the math in each option:

&{template:default} {{name=Skillroll}} {{?{Ability?|Strength,Strength=[[1d20+@{Strength}]]|Dexterity,Dexterity=[[1d20+@{Dexterity}]]} }}

Or you could even have it outside the query:

&{template:default} {{name=Skillroll}} {{?{Ability?|Strength,Strength=[[@{Strength}|Dexterity,Dexterity=[[@{Dexterity}}+1d20+@{other attributes}]] }}
June 15 (8 years ago)

Edited June 15 (8 years ago)
Anyway, here's the idea that I have, that is not 100% what I want, but seems to work close enough. It was actually Scott's idea that got me started on it. I did say, I need the value later as well, so I can do math, and that's why his idea doesn't work. However with a slight modification it does!

Let's say I query 2 attributes and then add them together, for a quick and easy template:

&{template:default} {{name=Test}} {{ ?{Attribute 1?|Strength,@{Strength}=Strength|Dexterity,@{Dexterity}=Dexterity }}} {{ ?{Attribute 2?|Strength,@{Strength} =Strength|Dexterity,@{Dexterity} =Dexterity }}} {{ [[ [[?{Attribute 1?}]] + [[?{Attribute 2?}]] ]]=Sum}}

Instead of "Dexterity 3" it will output "3 Dexterity" but I can live with that. Can't turn it around or the math doesn't work.

The "& #32;" in the second query is necessary, in case both values are the same (say 2), in which case the 2 from the second selection would overwrite the first one in the template, as they'd both have the same name. This way one is called "2" the other "2 " and it works.
If there were a third query, just add two of them, and so on.

Seems to work fine so far. 
June 15 (8 years ago)
Ziechael
Forum Champion
Sheet Author
API Scripter

Scott C. said:

@Ziechael

That won't work for queries though will it?
Could have sworn i had a version of it working that cheated the order of operations somehow but can't seem to replicate... will continue to play and post back if i get it up and running... d'oh
June 15 (8 years ago)

Edited June 15 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, I see what you are trying to do. Roll tags can help you quite a lot:

&{template:default} {{name=Test}} {{?{Attribute 1?|Strength,@{STR}[Strength]|Dexterity,@{DEX}[Dexterity]} }} {{ ?{Attribute 2?|Strength,@{STR}[Strength]|Dexterity,@{DEX}[Dexterity]} }}{{ [[ ?{Attribute 1?} + ?{Attribute 2?} ]]=Sum}}

Ah that's also a possibility. Thanks.