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

(Code Help JS) Disable button when corresponding value is 0

Hey all! Looking for some dev help :) I'm doing a re-worked version of the Coriolis character sheet and I've run into some problems! Background Coriolis is built on the Year Zero engine and has  Attributes (Strength, Agility)  and  Skills (Ranged Combat, Observation) A standard skill check is a dice pool consisting of ((Attribute*d6)+(Skill*d6)) dice, where every 6 rolled is a success You can make skill checks for basic skills (observation, attacks)  even though  you don't have any skill points in them You  can't  make skill checks for advanced skills (technology, science) if you have 0 skill points in them I'm trying to disable the roll buttons for all skills with the 'advanced' class if their corresponding value is 0 I've built this in codepen where it works flawlessly  but whenever I paste it into my sheet it stops working - from the wiki I've figured out it's got something to do with the script calling the document but I'm clueless how to adapt it for roll20. Any help would be very appreciated :) - Johan
1594027421

Edited 1594027479
Andreas J.
Forum Champion
Sheet Author
Translator
whenever I paste it into my sheet it stops working - from the wiki I've figured out it's got something to do with the script calling the document but I'm clueless how to adapt it for roll20. What wiki did you take this from? Roll20 have very limited use of JS. Read up on Sheetworkers , and on the character sheet creation process in general to understand what tools are at your disposal. You absolutely must read it to get get familiar with the basics if you want to work on character sheets, because Roll20 have a bunch of quirks and restrictions, and currently they are fairly well documented. <a href="https://wiki.roll20.net/Building_Character_Sheets#Restrictions" rel="nofollow">https://wiki.roll20.net/Building_Character_Sheets#Restrictions</a>
1594029085
GiGs
Pro
Sheet Author
API Scripter
Andreas is absolutely correct. I'm just adding some explanation: on roll20, you have no access to the DOM, so nothing in the script you have in the codepen will work on roll20. Sheet workers are very limited: they can only read and change attributes on the sheet. They cannot manipulate the sheet in any other way. To achieve your goal, the best roll20 method is probably using CSS: Have a CSS rule that switches which hides the button when the attribute's value is 0 (maybe show an object styled to look like a disabled button in its place). The CSS Wizardry page on the wiki covers this kind of thing.