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

Need Script Help - Basic Health Status Effects

1597026816

Edited 1597027955
This is the first API Script I'm trying to work on, but for some reason I can't seem to get it to work right. It keeps adding a number at the bottom of the status symbol. Below is the entirety of the script I am trying to write. on("change:graphic", function(obj) { // if the health bar has no maximum, don't do anything if(obj.get("bar1_max") === "") return; // if health is above 75%, draw Green Icon if(obj.get("bar1_value") >= obj.get("bar1_max") * 0.75) { obj.set("status_green"); } // remove green symbol if we are no longer above 75% health else { obj.set("status_green", false); } // if health is between 50% and 75%, draw Yellow Icon if(obj.get("bar1_value") >= obj.get("bar1_max") * 0.50 && obj.get("bar1_value") < obj.get("bar1_max") * 0.75) { obj.set("status_yellow"); } // remove yellow symbol if we are no longer between 50% and 75% health else { obj.set("status_yellow", false); } // if health is between 25% and 50%, draw brown Icon if(obj.get("bar1_value") >= obj.get("bar1_max") * 0.25 && obj.get("bar1_value") < obj.get("bar1_max") * 0.50) { obj.set("status_brown"); } // remove brown symbol if we are no longer between 25% and 50% health else { obj.set("status_brown", false); } // if health is between 0% and 25%, draw red Icon if(obj.get("bar1_value") > obj.get("bar1_max") * 0 && obj.get("bar1_value") < obj.get("bar1_max") * 0.25) { obj.set("status_red"); } // remove red symbol if we are no longer between 0% and 25% health else { obj.set("status_red", false); } // if health is at 0%, draw dead Icon if(obj.get("bar1_value") <= obj.get("bar1_max") * 0) { obj.set("status_skull"); } // remove dead symbol if we are no longer at 0% health else { obj.set("status_skull", false); } });
I'm not proficient enough in scripting to help much, but here's another script that intentionally adds numbers to status markers.&nbsp; Maybe that can help you track down the problem.&nbsp;&nbsp; <a href="https://wiki.roll20.net/Script:Flight" rel="nofollow">https://wiki.roll20.net/Script:Flight</a> And a different script that uses token auras to display health:&nbsp; <a href="https://app.roll20.net/forum/post/2139713/script-aura-slash-tint-healthcolor/?pagenum=1" rel="nofollow">https://app.roll20.net/forum/post/2139713/script-aura-slash-tint-healthcolor/?pagenum=1</a>
Here is another script that tracks the hp of tokens with Auras &amp; status markers. <a href="https://app.roll20.net/forum/post/6294497/script-deathtracker/?pageforid=6294497#post-6294497" rel="nofollow">https://app.roll20.net/forum/post/6294497/script-deathtracker/?pageforid=6294497#post-6294497</a>
1597062875
The Aaron
Roll20 Production Team
API Scripter
Try passing true for the second argument: obj.set("status_green" , true );
The Aaron said: Try passing true for the second argument: obj.set("status_green" , true ); That did it! Thank you so much!