Need help with basic scripting

I’m building a small 2D level for a level design class but there are some scripts that were not taught to us.
I need help with a basic health script that includes damage and death (restarting level) as well as the object that causes it.

I need a script that hurts/kills a player if they come into contact with it.
If the player touches “fire” he dies/gets hurt but if the player presses a key in front of the fire, he puts it out. I also need a script that ends the level when they touch an object.

I’m hoping to get help with this because I don’t know how to script and I’ve only been working with Unity for about 4-5 weeks and we have mostly touched building the level and not programming it.

If possible, I would also like to be able to make the player pick up an item; a key to open the door at the end and a fire extinguisher to put out the fires.

At the very least, could someone direct me as to where I could find the information to make these script??

Best i can do for you now is tell you that you hould create a var for health and damage

var health : int = 10;
var damage : int = 1;

then a function when your object is damaged.

function damageTaken()
{
health = health - damage;
if (health  == 0)
PlayerDead();
}

Thanks for your help.

Do you know how I can make object damage the player?

-------edit

applying the script to the player gives me an error “unknown identifier: ‘PlayerDead’”

not a big fan of scripting, makes me feel stupid XD

Look at collisions or triggers so…

function OnTriggerEnter(other : Collider)
{
if( other.tag == "enemy")
health = health - damage;
}

Thanks for the help. Do you know where I might find the information to make the rest of the scripts?

http://unity3d.com/support/documentation/ and google.

I will write you one here and now.
PlayerControler.js

var health : int= *user health*;
var maxhealth : int=*user health*;

function ApplyDmg(dmg : int) {
if (health==0) {AreWeDead();}
}

//private protects it from other scripts calling it
private function AreWeDead() {if(health==0){RestartGame();}}
private function RestartGame() {
//And there we meat creator! kidding, it will reload level
Application.LoadLevel(Application.loadedLevel);}

for dmg blocks there is this:
EnemyControler.js

var dmg=1;
function OnCollisionEnter(contact : Collider){
if( contact.tag == "hero") {contact.gameObject.GetComponent(PlayerControler).ApplyDmg(dmg);
}}
//make sure your main player has a tag "hero" on it.

well thats all for now as i am tired today.