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

[Help] Custom Character Sheet & Sheet Workers

Hi I need some help knowing if this is possible to do. I'm trying to use sheet worker to detect if an attribute is changed and then setting a status marker on the token/graphic. Not sure if I'm going about this the wrong way I have this: on("change:poison", function(eventInfo) {             console.log(eventInfo);             if (eventInfo.newValue > 0) {                 ??? .set({                     status_skull: eventInfo.newValue                 });             } }); Lost at that point on figuring out the player object that triggered the on change Thanks 
1576154990
GiGs
Pro
Sheet Author
API Scripter
Unfortunately you cant do that with code in the character sheet.  Tokens are separate from character sheets, and character sheets cant affect them.The only way to do this is with an API script. You can do it manually, with a script like TokenMod, or create a custom script to watch the attribute and update the status marker. Here's a very old script I used to use for one of my games, mostly cribbed from examples in the wiki. I'd write it differently now, but it still works: /**  * Set various token markers based on bar cur/max ratios  *   * The CONFIG array can have any number of configuration objects. These objects  * are processed in order. In the default version, it marks a character unconscious at 25% HP, * and dead at 0 hit points.  *   * barId - The ID of the bar to look at the values for [1, 2, 3]  * barRatio - The ratio of bar value to max value that triggers setting the status marker [0 - 1]  * status - The name of the status marker to toggle, eg skull, dead, etc.  * whenLow - The state of the marker when the bar value is <= the ratio [true, false] - it will be reversed when above that.  *  */ var CONFIG = [     {barId: 3, barRatio: 0.25, status: 'dead', whenLow: true},     {barId: 3, barRatio: 0, status: 'skull', whenLow: true}]; on('change:token', function(obj) {     CONFIG.forEach(function(opts) {         var maxValue = parseInt(obj.get('bar' + opts.barId + '_max'));         var curValue = parseInt(obj.get('bar' + opts.barId + '_value'));         log(opts.barId + ': ' + curValue + '/' + maxValue);              if (!isNaN(maxValue) && !isNaN(curValue)) {             var markerName = 'status_' + opts.status;             if (curValue < Math.round(maxValue * opts.barRatio)) {                 obj.set(markerName, opts.whenLow);             }             else {                 obj.set(markerName, !opts.whenLow);             }         }     }); });