Slxxpy said in Velocity Hud/Health Hud:
if(self.health >= 90) { self.healthText.glowcolor = (0.0, 1.0, 0.0); } else if(self.health >= 80) { self.healthText.glowcolor = (0.1, 0.9, 0.0); } else if(self.health >= 70) { self.healthText.glowcolor = (0.2, 0.8, 0.0); } else if(self.health >= 60) { self.healthText.glowcolor = (0.3, 0.7, 0.0); } else if(self.health >= 50) { self.healthText.glowcolor = (0.4, 0.6, 0.0); } else if(self.health >= 40) { self.healthText.glowcolor = (0.5, 0.5, 0.0); } else if(self.health >= 30) { self.healthText.glowcolor = (0.6, 0.4, 0.0); } else if(self.health >= 20) { self.healthText.glowcolor = (0.7, 0.3, 0.0); } else if(self.health >= 10) { self.healthText.glowcolor = (0.8, 0.2, 0.0); } else if(self.health >= 0) { self.healthText.glowcolor = (1.0, 0.0, 0.0); }
You can do something like this instead of using so many ifs
self.healthText.glowcolor = (
1.0 - self.health / 100,
self.health / 100,
0.0
);
Which will calculate values like this
100 hp = (0.0, 1.0, 0.0)
90hp = (0.1, 0.9, 0.0)
...
10hp = (0.9, 0.1, 0.0)
0hp = (1.0, 0.0, 0.0)