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);
}
});