flashLight regeneration

**Hi i need some help i would like to make the Flash light regeneration
when the flashlight is off it should regeneration the light
Here is a script i found for the flashlight to turn off it has audio source and BatteryLife!!! the battery life is only for flashlight how much battery it has till it dosent turn off **

so basically could any one know how to add Regeneration in this script? when the flashlight is off the battery is charing

Sorry for bad eng :stuck_out_tongue:

#pragma strict

var flashlightLightSource : Light;
var lightOn : boolean = true;
var lightDrain : float = 0.1;
var batteryLife : float = 0.0;
var maxBatteryLife : float = 2.0;

var barDisplay : float = 0;
var pos : Vector2 = new Vector2(20,40);
var size : Vector2 = new Vector2(60,20);
var progressBarEmpty : Texture2D;
var progressBarFull : Texture2D;

var soundTurnOn : AudioClip;
var soundTurnOff : AudioClip;


function Start()
{
	batteryLife = maxBatteryLife;
	flashlightLightSource = GetComponent(Light);
}

function Update()
{

//BATTERY LIFE BRIGHTNESS//////////
	if(lightOn && batteryLife >= 0)
	{
		batteryLife -= Time.deltaTime * lightDrain;
	}
		if(lightOn && batteryLife <= 0.4)
	{
		flashlightLightSource.light.intensity = 0.4;
	}
		if(lightOn && batteryLife <= 0.3)
	{
		flashlightLightSource.light.intensity = 0.8;
	}
	if(lightOn && batteryLife <= 0.2)
	{
		flashlightLightSource.light.intensity = 0.4;
	}
		if(lightOn && batteryLife <= 0.1)
	{
		flashlightLightSource.light.intensity = 0.2;
	}
			if(lightOn && batteryLife <= 0)
	{
		flashlightLightSource.light.intensity = 0;
	}
	

	
	barDisplay = batteryLife;
	
	if(batteryLife <= 0)
	{
		batteryLife = 0;
		lightOn = false;
	}
	
	if(Input.GetKeyUp(KeyCode.F))
	{
		toggleFlashlight();
		toggleFlashlightSFX();
		
		if(lightOn)
		{
			lightOn = false;
		}
		else if (!lightOn && batteryLife >= 0)
		{
			lightOn = true;
		}
	}
}
	
	/////// PIC  ///////////
function OnGUI()
{
 
    // draw the background:
    GUI.BeginGroup (new Rect (pos.x, pos.y, size.x, size.y));
        GUI.Box (Rect (0,0, size.x, size.y),progressBarEmpty);
 
        // draw the filled-in part:
        GUI.BeginGroup (new Rect (0, 0, size.x * barDisplay, size.y));
            GUI.Box (Rect (0,0, size.x, size.y),progressBarFull);
        GUI.EndGroup ();
 
    GUI.EndGroup ();
 
} 
 	
function toggleFlashlight()
{
	if(lightOn)
	{
		flashlightLightSource.enabled = false;
	}
	else
	{
		flashlightLightSource.enabled = true;
	}
}
function toggleFlashlightSFX()
{
	if(flashlightLightSource.enabled)
	{
		audio.clip = soundTurnOn;
	}
	else
	{
		audio.clip = soundTurnOff;
	}
	audio.Play();
	
}

	@script RequireComponent(AudioSource)

after your life drain if checks, add:

if(!lightOn && batteryLife <= maxBatterLife)
{
  batterLife += Time.deltaTime * lightDrain;
}