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

Implementing "spending" dice in character sheet.

The game I'm working with has a mechanic where you can use dice from a set of resource pools to augment a basic roll. There might be several and a single pool might have different dice e.g. 2 X d6, d10,  d12. At the moment I've got my character sheet set up with a list of pools and the associated dice from each as a group of checkboxes for each pool. You check the ones you want to use and they are incorporated into the roll when it's made. The pools and the dice in them are permanent parts of the character build. The system says that, once rolled, these special dice are temporarily used up and can't be reused for another roll until a reset condition is met (which reinstates a whole pool). I have an attribute that stores which dice are currently selected (as a JSON) to be added to the next roll. I also have an attribute that stores the dice that are currently "spent". Is there a way to use this last attribute in the character sheet to make those checkboxes become hidden/unselectable, as part of  the roll mechanic and then reappear when another action is carried out, like clicking a reset button.
1592316525
GiGs
Pro
Sheet Author
API Scripter
Unfortunately not, at least not as part of a character sheet. You can do it with an API Script. There are two kinds of buttons available in a character sheet: roll buttons and action buttons. A roll button sends text and rolls to chat. An action button makes changes to the character sheet's attributes (like reducing resources). There's no way to combine these two with just character sheet code -  they are completely separate. Using an API script like chatSetAttr or ammo, you can alter attributes. You could create rolls which do your roll, and also include a command to trigger the script.
OK. In a normal web page i'd use javascript to add a class to the controls I wanted to go away, and let CSS hide it. I assumed that this something roll20 would block. Are you able to steer me to an example of an API script that alters the visibility/intractability of a character sheet control?
Or alternatively a way to conditionally hide a character sheet control based on the value of the attr it's attached to.
Oh and thanks GiGs for always being there.
1592332037
Finderski
Plus
Sheet Author
Compendium Curator
You can place a hidden input with the exact same name of the field that has the value to control whether something is hidden. Then you set up your CSS to hide the field based on the value of the hidden field.  Does that make sense? The difficult part would be unhiding it if you can't change the value of the field again. However, you can also use an action button to change the values of fields. Action buttons don't send anything to chat but can be recognized by sheet workers via on clicked.
1592347296
GiGs
Pro
Sheet Author
API Scripter
Thank you for the kind words, James. Finderski mentions the basic options. The CSS Wizardry page on the wiki has some examples of using Attribute values and CSS to conditionally show and hide divs and other elements. Since these are controlled hy attribute value, any method of changing the attribute value will work - chatSetAttr is a great script for doing this. If you're doing it direct from the character sheet, an Action Button as Finderski suggested is a great way to do it, but I think you need to do it through a roll. In that case, appending or prepending a chatSetAttr or similar script command to your roll is the normal way to do this.