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 .
×

Non-Math Conditionals

Hello. I am trying to build a custom character sheet for my game. However, I can't seem to figure out how to include non-mathematical conditionals. Looking around, it seems normal if/then html coding doesn't work, and I'm not sure sheetworker and macros work that way. Essentially, each class in my game starts with a given bonus. I am trying to program it so that, when choosing a class, the bonus will automatically be displayed as well.  Any advice?
1563205959
Finderski
Pro
Sheet Author
Compendium Curator
You can accomplish this with a sheet worker.  For additional help, we'd need to know more about the specifics, though. :)
1563209869

Edited 1563209933
vÍnce
Pro
Sheet Author
Michael H. said: Hello. I am trying to build a custom character sheet for my game. However, I can't seem to figure out how to include non-mathematical conditionals. Looking around, it seems normal if/then html coding doesn't work, and I'm not sure sheetworker and macros work that way. Essentially, each class in my game starts with a given bonus. I am trying to program it so that, when choosing a class, the bonus will automatically be displayed as well.  Any advice? So, are the bonuses just text that you want displayed if they choose a given class?
1563228207
GiGs
Pro
Sheet Author
API Scripter
As Finderski says, this sounds like a pretty simple task to handle in a sheet worker with 4 bits if information: the list of classes, the name of the attribute that contains the chosen class, the text you want displayed, and the name of the attribute where it will be displayed. The basic version of the sheet worker would look something like, assuming  the attributes are named 'class' and 'class_bonus'. on ( "change:class" , function () { getAttrs ([ "class" ], function (values) { var class = values.class; var bonus = '';       if (class === 'fighter') bonus = 'fighter bonus'; else if (class = 'rogue') bonus = 'rogue bonus'; else if (class = 'bard') bonus = 'bard bonus'; // and so on setAttrs({          class_bonus: bonus }); }); }); There are better ways to build this sheet worker, but this should be easy-ish to understand.  It can get a little more complicated depending on what you want the bonus to do (like if it affects different stats), but it will be solvable if you can describe the specific details.