var scriptName = "DamageIndicator"; 
var scriptVersion = 1.0; 
var scriptAuthor = "soulplexis";

var exampleModule = new ExampleModule();
var exampleModuleClient;

// this part made by Senk Ju  simply alternates between colors in a message ////
var colorIndex = 0;
function printMessage(message) {
    var availableColors = ["§8[§b§lLiquidBounce§8] §b", "§8[§b§lLiquidBounce§8] §3"];

    var color = availableColors[colorIndex];
    
    colorIndex += 1;
    if (colorIndex >= availableColors.length) {
        colorIndex = 0;
    }

    chat.print(color + message + "§r");

}
////////////////////////////////////////////////////////////////////////////////

function ExampleModule() {
	var ticks = 0;
    this.getName = function() {
        return "LowHealth";
    };

    this.getDescription = function() {
        return "Warns you when you have low health.";
    };

    this.getCategory = function() {
        return "Render";
    };

    this.onUpdate = function() {
		if(mc.thePlayer.getHealth() <= 0) {
			printMessage("You seem to have died.");
		}	
		if(mc.thePlayer.getHealth() <= 7) {
			ticks++;
			if(ticks >= mc.thePlayer.getHealth() + 20) {
			printMessage("HEY! Your health is low.");
			ticks = 0;
			}
		} else {
			if(ticks > 0) {
				printMessage("Your health is returning.");
				ticks = 0;
			}
		}
	}
	this.onDisable = function() {
	}
}

function onLoad() {
};

function onEnable() {
    exampleModuleClient = moduleManager.registerModule(exampleModule);
};

function onDisable() {
    moduleManager.unregisterModule(exampleModuleClient);
};