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

Conditional values in a roll button?

1600651732
Eric
Sheet Author
Hi, I have two attributes for weapon damage bonus: melee and ranged. These attributes are global to the whole sheet, not inside any repeating section. In the repeating weapon section, each weapon has a "type" attribute: melee or ranged, as well as a single roll button to roll the damage for that weapon.  What is the strategy for adding in one of the damage bonus attributes, depending on the type of the weapon, in the roll button macro? Or is there another approach? I thought initially would just make the button an action button and do the logic in the clicked script ... but alas it seems action buttons cannot cause rolls or send chat.
1600684972
GiGs
Pro
Sheet Author
API Scripter
You are correct that action buttons cannot cause rolls or send chat. There is more than one way to do what you want. For reference, when asking for help, its a good idea to include the exact  attribute names, as they are used on the sheet, and the html, css, and/or javascript related to the question. It's much easier to give accurate help. The simplest way to handle this would be to make sure the type attribute is a select, and in the option values are attribute calls for the weapon damage bonuses, like <option value="@{weapon_damage_bonus_melee}" or whatever the melee attribute is called. Then in your button value, you just have a call to that select instead, like "+@{type}" and it will use the selected value.
1600745996
Eric
Sheet Author
Awesome! Thank you. 
1600784591
GiGs
Pro
Sheet Author
API Scripter
you're welcome :)