Blender 2.5 health bar problem!

Hello.I need a health bar for my game…but the script work on 2.49…i want to make it work on 2.5.
I ve done some modifications to this script

import bge

cont = bge.logic.getCurrentController()
obj = cont.owner
obj.percent = obj.health * 100 / obj.healthMax

but i get this error in console.:frowning:
Attribute error: KX_GameObject object has no attribute “health”

I cant figure it out,maybe you guys can help me.
Thx.

Change the line
obj.percent = obj.health * 100 / obj.healthMax to
obj[‘percent’] = obj[‘health’] * 100 / obj[‘healthMax’]
http://blenderarchive.hostilestudios.com/about.php#backwardscompatible

THX!!! YOU are my HERO!!

If you want a more in depth look at the API changes between 2.4x and 2.5, take a look at this article:

and here’s my ongoing list of GameLogic code that is now deprecated:
http://blenderarchive.hostilestudios.com/about.php#backwardscompatible

thx guys! thx alot.

the link is not working.

yeah, server is being moved at the moment :@
will be up this week !