local function UnitIterator() local pmem, rmem = GetNumPartyMembers(), GetNumRaidMembers() local playersent = false local petsent = false local unitcount = 1 local petcount = 1 local unit, name return function() -- blah blah if rmem > 0 then -- STEP 3a: pet units for i = petcount, rmem do unit = string.format("raidpet%d", i) petcount = petcount + 1 name = GetName(unit) if name and not UnitIsCharmed(unit) then return unit, name end end -- STEP 3b: player units for i = unitcount, rmem do unit = string.format("raid%d", i) unitcount = unitcount + 1 name = GetName(unit) if name then return unit, name end end -- blah blah end endend