Are you telling your lua to differentiate between specific spells or have you kept it generalized to things like elemental or dark magic? If the latter, it sounds like it's defaulting to whatever you associate to that spell tree so it gets swapped mid-cast.
XI Wiki


