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

Adjust a dropdown menu on a character sheet by macro?

May 07 (3 years ago)

Is there a script that will allow me to change which option is selected on a character sheet's dropdown by macro? Thanks in advance!

May 07 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Probably ChatSetAttr can write whatever value you want in there, but would require testing with whatever specific sheet and field you are interested in working with.

May 07 (3 years ago)

Thanks for the reply.

I played around with ChatSetAttr, but unless I'm missing something it does not have any effect on an attribute that's set up in the sheet as a dropdown menu; only those set up as text or number fields.

May 07 (3 years ago)

Let me clarify what I'm asking. Let's say you have a dropdown menu in the character sheet labelled 'Proficient?', with options 'Yes' or 'No'. The default is set to 'No'. If you adjust it, it changes some attribute on which other rolls rely.

Using chatsetattr, I can adjust that attribute to whatever it should be if 'Yes' was selected, but on the character sheet it will still look like 'No' is selected.

May 07 (3 years ago)
GiGs
Pro
Sheet Author
API Scripter

It sounds like that dropdown triggers a sheet worker that changes some other things, which gives you options:

  1. Use chatsetattr to change the dropdown and the attributes the dropdown changes
  2. Change the dropdown, and relying on chatsetattr triggering the sheet worker and hope it all works automatically

The second part should just work, but in my experience it doesn't always.

May 07 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Exactly what GiGs said. 

Which sheet and attribute are you trying to modify?

May 08 (3 years ago)

I'm using Axel Mellgren's sheet for WFRP 2e. It has a lot of dropdown selects. Here's an example; selecting if you're trained in the Charm skill.

    <select class="sheet-select-no-arrow-center" name="attr_Skill_Charm">
                            <option value="floor((@{Fellowship})/2)" selected="selected">&#8212;</option>
                            <option value="@{Fellowship}" data-i18n="TRAINED">Trained</option>
                            <option value="@{Fellowship}+10">+10%</option>
                            <option value="@{Fellowship}+20">+20%</option>
                        </select>

It's easy enough to modify the value of the attribute, but I don't see how to change what the dropdown displays.

May 08 (3 years ago)

Edited May 08 (3 years ago)
GiGs
Pro
Sheet Author
API Scripter

Ah thats tricky. The option value is what you need to set, and you need to set the exact text an item has: "@{Fellowship}" or "floor((@{Fellowship})/2)", etc.

Don't set the score, set that exact text.

May 08 (3 years ago)

I had tried that to no avail, but I think I have figured out the problem, if not the solution. It's the @. Chatsetattr does not input that into the value but acts as if I'm using it to reference something else.

May 08 (3 years ago)

Edited May 08 (3 years ago)
GiGs
Pro
Sheet Author
API Scripter

It probably isnt chatsetAtrrs doing that, but roll20 standard parsing, which always tries to convert attribute calls to their values.

You can try entering the html entity &#64; instead of @, like

&#64;{Fellowship}


Chatsetattr might itself have syntax for handling this, but i can't remember.

May 08 (3 years ago)

Edited May 08 (3 years ago)

Normal html replacement doesn't work, but I found that chatsetattr does have a --replace option that converts ` to @.

Finally got it working! Thanks for the patience with my confusion.

May 08 (3 years ago)
GiGs
Pro
Sheet Author
API Scripter

great :)