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

Is there a way to not affect PC's with Bloodied and Dead Status Markers script?

I'm using a slightly modified version of the Bloodied and Dead Status Markers script, as you can see below (just tints instead of markers, bloodied on 1/3, and a different bar) on("change:graphic", function(obj) { if(obj.get("bar3_max") === "") return; if(obj.get("bar3_value") <= obj.get("bar3_max") / 3) { obj.set({ tint_color: "#ad0000" }); } else{ obj.set({ tint_color: "transparent" }) } if(obj.get("bar3_value") <= 0) { obj.set({ status_dead: true, tint_color: "#000000" }); } else { obj.set({ status_dead: false }); } }) It's a bit awkward for players to get a big red X on their token when their health drops to 0 in D&D 5e, since they're not technically dead, just unconscious. I assume there is a way for the dead status marker to only appear on non-PC tokens, but I wouldn't know where to start for adding this feature (I'm new to the API and a very poor/amateur coder) so any help would be appreciated. Thanks in advance.
1505044108
Jakob
Sheet Author
API Scripter
The thing you would check for is the 'controlledby' property on the token or character: const controlledby = (getObj('character', obj.get('represents')) || obj).get('controlledby'); if(obj.get("bar3_value") <= 0 && !controlledby) { obj.set({ status_dead: true, tint_color: "#000000" }); } else if (!controlledby) { obj.set({ status_dead: false }); } controlledby will be an empty string if and only if the character/token cannot be controlled by any player.
Ah of course, I'd seen that being mentioned before but never put two and two together. Thanks for the help Jakob!