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

Nested Query rolls in custom sheet

1625096530

Edited 1625102302
I've been burning my few last brain cells left trying to make this work, but I'm not even sure it's possible nor if I'm in the right path. My idea is to allow for the user to determine which type of roll will be used through a popup prompt. so far I have these two rolls that work just fine on their own: <button name="roll_spell1" type="roll" value="@{whisper_toggle} &{template:eclipse}{{roll=[[1d100]]}}{{name="test2"}}"> <button name="roll_spell2" type="roll" value="@{whisper_toggle} &{template:eclipse}{{roll=[[4d20]]}}{{name=@{test}}}"> And what I've been trying to do was using the ?{} query to try and nest both of them together. Such as: <button name="roll_spell3" type="roll" value="?{Dice Type | Example 1,@{whisper_toggle} &{template:eclipse}{{roll=[[1d100]]}}{{name=@{test}}} | Example 2,@{whisper_toggle} &{template:eclipse}{{roll=[[4d20]]}}{{name="test2"}} } And according the rules in the wiki, replacing any problematic characters  & = &amp and } = } <button name="roll_spell3" type="roll" value="?{Dice Type | Example 1,@{whisper_toggle} &amp{template:eclipse}{{roll=[[1d100]]}}{{name=@{test}}}|Example 2,@{whisper_toggle} &amp{template:eclipse } {{roll=[[4d20]]}}{{name="test2"}}}"> But once I try running the code it returns a  free-form text field instead of a dropdown filled with: Example 1, 0 &{template:eclipse I feel like I missed something, but I'm not sure what. :/
1625099338

Edited 1625099516
GiGs
Pro
Sheet Author
API Scripter
I dont know if this is your issue, but for & its & note the ; at the end. Later, you also have &#125{template: - HTML entities always need a semi-colon as their ending. That doesn't seem like the right entity there, either.
1625099911

Edited 1625099931
GiGs
Pro
Sheet Author
API Scripter
I would also suggest - move everything that is shared in each roll out of the query. The both start with @{whisper_toggle} &{template:eclipse}{{roll= so put that before the query, like @{whisper_toggle} &{template:eclipse}{{roll=?{Dice Type | Example 1,[[4d20]]}}{{name=@{test}| Example 2,[[1d100]]}}{{name=@{test2}} }} Then you have much fewer substitutions to deal with.
1625104199

Edited 1625104321
As to what was on the first reply, it was just a misstype when bringing it to the forum, just corrected it. That doesn't seem to be the issue. As to the second repl y, I have tried that as well, but it just returned the same text box, but with: Example 1, [[1d100]] It seems like it's recognizing the } as a regular } in the code and closing the querry whenever it meets one  
1625112149
Kraynic
Pro
Sheet Author
    Does it have to be a query?  How many options are there?  If it is just a couple, there could just be a set of radio button toggles near the roll button (or the section of the sheet that it is in) that set what roll calculation is being used.  Unless it is being changed really often, that might be more convenient than answering a query every time.
I could replace the querry by a number input, but the querry seemed more user-friendly and straightforward than that. =/  The value provided by the user will effect how many times some elements inside the roll might repeat I will be using that as last resort, cause I still feel the querry would fit better for the sittuation:/
1625128732
Finderski
Plus
Sheet Author
Compendium Curator
Rather than trying to put the roll formulas in the query have you tried putting them in hidden attributes and just calling those hidden attributes? <input type="hidden" name="attr_formula1" value='@{whisper_toggle} &{template:eclipse}{{roll=[[1d100]]}}{{name=test2}}' /> <input type="hidden" name="attr_formula2" value="@{whisper_toggle} &{template:eclipse}{{roll=[[4d20]]}}{{name=@{test}}}" /> <button name="roll_spell3" type="roll" value="?{Dice Type | Example 1, @{formula1} | Example 2, @{formula2}}></button> Not sure if you'd still need HTML substitution for that or not...
1625136295

Edited 1625137874
GiGs
Pro
Sheet Author
API Scripter
You'd still need html substitution for that Finderski - remember a macro expands to include all attribute values before processing it. Arnoldo, IIRC the problem here might be character sheets apply an extra level of processing. The macro I posted works when run from a character ability or directly in chat. But in a character sheet you might need to add an extra & before each HTML entity, like so: @{whisper_toggle} &{template:eclipse}{{roll=?{Dice Type | Example 1,[[4d20]]}&}{{name=@{test}| Example 2,[[1d100]]&}&}{{name=@{test2}} }} Though I avoid using nested queries like the plague, so if that doesn't work, I'm out of ideas. ARNOLDO B. said: It seems like it's recognizing the } as a regular } in the code and closing the querry whenever it meets one   This is exactly why HTML entities are needed in nested queries - so that roll20 doesn't recognise the },| characters and terminate the query early.
1625142808
Finderski
Plus
Sheet Author
Compendium Curator
GiGs said: Though I avoid using nested queries like the plague, so if that doesn't work, I'm out of ideas. Me, too...which is why I was uncertain if my stuff would help. LOL
GiGs said: You'd still need html substitution for that Finderski - remember a macro expands to include all attribute values before processing it. Arnoldo, IIRC the problem here might be character sheets apply an extra level of processing. The macro I posted works when run from a character ability or directly in chat. But in a character sheet you might need to add an extra & before each HTML entity, like so: @{whisper_toggle} &{template:eclipse}{{roll=?{Dice Type | Example 1,[[4d20]]}&}{{name=@{test}| Example 2,[[1d100]]&}&}{{name=@{test2}} }} Though I avoid using nested queries like the plague, so if that doesn't work, I'm out of ideas. Yup, now that seemed to have done trick, now it's showing the dropdown as expected, an odd solution but it works haha. Will be doing some more testing around here and update here if necessary. Thank for the help! :D
1625164214

Edited 1625164291
GiGs
Pro
Sheet Author
API Scripter
Yay! You're welcome. Though looking at my code, I might have a few too many &'s in it. Should it be @{whisper_toggle} &{template:eclipse}{{roll=?{Dice Type | Example 1,[[4d20]]}}{{name=@{test}| Example 2,[[1d100]]}}{{name=@{test2}} }}
1625176340

Edited 1625176635
vÍnce
Pro
Sheet Author
I think the extra ampersand substitution in addition to the regular html substitutions on nested queries is an issue recently introduced with the CSE update.&nbsp; Devs are working on fixing these parsing issues later... <a href="https://app.roll20.net/forum/permalink/10071671/" rel="nofollow">https://app.roll20.net/forum/permalink/10071671/</a> <a href="https://app.roll20.net/forum/permalink/10112678/" rel="nofollow">https://app.roll20.net/forum/permalink/10112678/</a>
1625225565
GiGs
Pro
Sheet Author
API Scripter
So when they do fix them, people will have to rewrite their sheets to work again, lol. Thanks vInce.
1625266573
vÍnce
Pro
Sheet Author
;-)
Thanks for the help ^^