All pastes #146824 Raw Edit

Mine

public lua v1 · immutable
#146824 ·published 2006-08-23 22:17 UTC
rendered paste body
local function unititer(pmem, rmem, playersent, petsent, unitcount, petcount)	-- STEP 1: pet	if not petsent then		petsent = true		if rmem == 0 then			unit = "pet"			name = GetName(unit)			if name and not UnitIsCharmed(unit) then				return unit, name			end		end	end	-- STEP 2: player	if not playersent then		playersent = true		if rmem == 0 then			unit = "player"			name = GetName(unit)			if name then				return unit, name			end		end	end	-- STEP 3: raid units	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	-- STEP 4: party units	elseif pmem > 0 then		-- STEP 3a: pet units		for i = petcount, pmem do			unit = string.format("partypet%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, pmem do			unit = string.format("party%d", i)			unitcount = unitcount + 1			name = GetName(unit)			if name then				return unit, name			end		end	endendlocal function UnitIterator()	local pmem, rmem = GetNumPartyMembers(), GetNumRaidMembers()	local playersent = false	local petsent = false	local unitcount = 1	local petcount = 1	local unit, name	return unititer, pmem, rmem, playersent, petsent, unitcount, petcountend