absolutly great EM never would have thought of a loop there
ok now to hit the cast wait and the spell cooldowns woot
Another thing you could do is put that med check into each check to cast each specific spell, and if the spell needs to be cast, then check to see if there's enough mana, and if there's NOT enough mana, set the %med to whatever that SPECIFIC spells mana - lmc) requirement is.

That way it meds to that spells mana requirement as fast as possible and the script is more efficient... does that make sense?

You could also have a med active check so med doesn't get interrupted... Like a repeat until %mana = !manarequiredforspecificspell then continue type deal.

Not sure how you want to use this script tho, I didn't read the top of the script. I should do that.