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?

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!
1651953308
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.
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.
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.
1651958387
GiGs
Pro
Sheet Author
API Scripter
It sounds like that dropdown triggers a sheet worker that changes some other things, which gives you options: Use chatsetattr to change the dropdown and the attributes the dropdown changes 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.
1651960541
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Exactly what GiGs said.  Which sheet and attribute are you trying to modify?
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">—</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.
1651998407

Edited 1651998429
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.
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.
1652004845

Edited 1652004883
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 @ instead of @, like @{Fellowship} Chatsetattr might itself have syntax for handling this, but i can't remember.
1652005665

Edited 1652005677
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.
1652008530
GiGs
Pro
Sheet Author
API Scripter
great :)