local damagerestore = {delay = 0}
function damagerestore:think()
	if game.player.destroyed then return 1 end
	self.delay = self.delay + 1
	if game.player.extracounter>=40 and 
			Keyboard.isKeyDown("R") and 
			self.delay>20 and 
			game.player.hp<100 then
		self.delay = 0
		game.player.hp = 100
		game.player.extracounter = 
			game.player.extracounter - 40
	end
end

game:addthink(damagerestore)