Warcraft III resources & community, 2003–2006 · archived

IterateGroup

not rated
Submitted by AltSubmitterExecution0 downloads
Lets you iterate a unit group without a ForGroup call. This way you can do an action on all units in a unit group without having to call another function, which is useful if you're referencing locals, or if you want to do a unit group within a unit group without losing the reference to the EnumUnit of the original group.

Source

function IterateGroup takes group whichGroup, integer unitindex returns unit
    local group Units2Iterate = CreateGroup()
    local unit tempUnit = null
    local integer i = 1

    call GroupAddGroup(whichGroup, Units2Iterate)

    loop
        set tempUnit = FirstOfGroup(Units2Iterate)
        exitwhen tempUnit == null or i >= unitindex
        call GroupRemoveUnitSimple( tempUnit, Units2Iterate )
        set tempUnit = null
        set i = i + 1
    endloop

    call DestroyGroup(Units2Iterate)

    return tempUnit
endfunction

Comments

0

No comments.