Droidz,
Thank you so much for this. It works, and I have been able to level several pets very nicely.
I would like to add a suggestion for an enhancement to this lua script.
Sometimes, as the leveling pet in slot 1 gets higher, the bot uses one of the 'advanced' spells...the spells that are learned at level 15 and 20. This is not desirable because it may cause the leveling pet to be unable to be swapped. For example, the battle pet Drenei Micro Defender, or Chrominius, or Legs...many many pets have spells, that if used, cause it to be unswappable or even to be killed.
For ideal pet leveling, the first pet would simply use spell #1 once, then swap. That's all.
Regardless, your bot is wonderful.