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

Switching aspects of a character sheet based on

1538644698

Edited 1538644758
EDIT: Title had "<switch>" (the HTML tag) in it but I guess that part got removed. This post is asking about drop-down menus, essentially. Is there a fairly simple (or, withstanding, a not-so simple) way to do this? Let's say for example you wanted a drop down with specific races, and whichever race you pick determines certain attributes/stats, changes the values or limits them. How would I go about doing this? I have a basic understanding of HTML and CSS (although the latter won't help me much here, I figure) and a shoddy understanding of Javascript, especially when it's restricted by the current limitations. Is this impossible, or just difficult? Or neither? I've tried looking around to no avail and several, much older posts suggest that it isn't really possible, but I'm hoping that information is outdated.
1538652000

Edited 1538652033
Finderski
Pro
Sheet Author
Compendium Curator
This is possible using sheet workers.  Essentially, you'd watch that field for a change, and when there's a change you would use setAttrs to set the values of different attributes/stats. Here's an example that watches the attr_xp, attr_rank, and attr_class fields, and when a change is made it does an evaluation and sets the value of two fields (Rank and Class—the same two the script is watching for a change, but when watching for a change, everything needs to be lowercase and you drop the attr_ prefix). //Set Rank according to the XP value on("sheet:opened change:xp change:rank", function() { getAttrs(["xp", "rank", "class"], function(value) { console.log("xp value: " + value.xp); console.log("rank value: " + value.rank); let xpVal = parseInt(value.xp)||0; console.log(xpVal); if (xpVal >=80) { console.log("Setting rank to Legendary"); setAttrs({Rank: 5}); console.log("Setting class to Grad Student"); setAttrs({Class: 5}); } else if (xpVal >=60) { console.log("Setting rank to Heroic"); setAttrs({Rank: 4}); console.log("Setting class to Senior"); setAttrs({Class: 4}); } else if (xpVal >=40) { console.log("Setting rank to Veteran"); setAttrs({Rank: 3}); console.log("Setting class to Junior"); setAttrs({Class: 3}); } else if (xpVal >=20) { console.log("Setting rank to Seasoned"); setAttrs({Rank: 2}); console.log("Setting class to Sophmore"); setAttrs({Class: 2}); } else { console.log("Setting rank to Novice"); setAttrs({Rank: 1}); console.log("Setting class to Freshman"); setAttrs({Class: 1}); } }); }); //End Rank Hope that helps.
This helps a lot. Thanks!