Help with health meter

Ive started a health meter for my zelda game and havnt been able to get it to work correctly. The game starts the health at 30 and three hearts are showing. If you go directly to the heart with 30 life still intact it will add up correctly to 40 and show 4 hearts filled up. But if you go over to the enemey and loose life then go to the heart it wont add up to 40 and show all the hearts filled. I was wondering if anyone had a good math equation or somthing to make this work. Thank you in advance