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

Roll query, but default to the second or third option?

February 21 (8 years ago)
Kryx
Pro
Sheet Author
API Scripter
I have a roll query:
?{Roll|Normal,d20|Advantage,2d20kh1|Disadvantage,2d20kl1}
Is it possible to have a similar roll query, but have Advantage or Disadvantage be the default state?
February 21 (8 years ago)
Ziechael
Forum Champion
Sheet Author
API Scripter
I hate to potentially suggest the obvious as you may have a more complex use case in mind but:
?{Roll|Advantage,2d20kh1|Disadvantage,2d20kl1|Normal,d20}
or
?{Roll|Disadvantage,2d20kl1|Advantage,2d20kh1|Normal,d20}
February 21 (8 years ago)

Edited February 21 (8 years ago)
Kryx
Pro
Sheet Author
API Scripter
I'd like the order to remain the same, just have a different option selected by default. The same as "selected" with a <select> element.

Presenting a different order isn't such a good user experience. :(
February 21 (8 years ago)
Ziechael
Forum Champion
Sheet Author
API Scripter
I figured it would be slightly more complex than first appearances suggested lol... I'm sure Silvyre will be by with some dark magic that can alter reality using mathematics... or at least confirm that it can't be done ;)
February 21 (8 years ago)

Edited February 21 (8 years ago)
I sometimes think about this in regards to series like ranges (short, medium, long), but I'm pretty sure it can't be done in a roll query.

One imperfect workaround is to duplicate the default choice and put it at the beginning.

?{Range| Medium, +0 | Short, +1 | Medium, +0 | Long, -1}

The drop-down list is now in order, except for the default option being duplicated at the top.

Your roll query would be

?{Roll|Advantage,2d20kh1|Normal,d20|Advantage,2d20kh1|Disadvantage,2d20kl1}
February 21 (8 years ago)
Seconding David T.'s workaround.
February 21 (8 years ago)
Hrm, that is an interesting workaround... something that should be adjustable with sheetworkers right?
February 21 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
wouldn't even need sheetworkers directly, just set the roll query up as:

?{Roll with|@{advantageDefault}|Normal,d20|Advantage,2d20kh1|Disadvantageous,2d20kl1}

And then your sheetworkers change advantageDefault based on what the sheet is set to.
February 21 (8 years ago)
The Aaron
Pro
API Scripter
This is exactly what I do for the Vignette Configuration in ColorEmote:
    getConfigOption_VignetteMode = function() {
        return makeConfigOption(
            state.ColorEmote.config.vignetteMode+symbols.dropDown,
            '!cem-config --set-vignette-mode ?{Vignette Mode|'+
            state.ColorEmote.config.vignetteMode+' (current),'+ state.ColorEmote.config.vignetteMode+'|'+
            _.keys(vignetteModes).join('|')+'}',
            '<b>Vignette Mode</b> determines how the representative image is framed and clipped.'
        );
    },
with the addition that I label it as (current) when it's in the first place.
February 21 (8 years ago)

Edited February 21 (8 years ago)
Scott C. said:
wouldn't even need sheetworkers directly, just set the roll query up as:

?{Roll with|@{advantageDefault}|Normal,d20|Advantage,2d20kh1|Disadvantageous,2d20kl1}

And then your sheetworkers change advantageDefault based on what the sheet is set to.

That would require html character replacement though maybe.
February 21 (8 years ago)

Edited February 21 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

SkyCaptainXIII said:

Scott C. said:
wouldn't even need sheetworkers directly, just set the roll query up as:

?{Roll with|@{advantageDefault}|Normal,d20|Advantage,2d20kh1|Disadvantageous,2d20kl1}

And then your sheetworkers change advantageDefault based on what the sheet is set to.

That would require html character replacement though maybe.

nope, the attribute gets replaced with its value before the roll query is resolved, so as long as you don't have problem characters in your advantageDefault, you're good. It's the most common mistake when doing advanced nested dropdown menus, figuring out exactly which curly braces, bars, and commas need to be replaced and which are parsed out by the chat prior to the roll query can be a real pain in the butt.

EDIT: Tangentially related; I really need to find some time and correct the wiki on order of operations since it is completely incorrect about the recursiveness of evaluating attributes, abilities, and roll queries.
February 21 (8 years ago)
Kryx
Pro
Sheet Author
API Scripter
Blah, no way to keep the normal order but change the selected item :(