• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

GroupEnum... not working?

Status
Not open for further replies.

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,550
There have been several occasions where GroupEnum functions do nothing.

For example, I was trying to do pick every unit in a radius, and then send them to another location (set by coordinates). Anyway, that matters little.
[JASS=The scripting is based around this]function ScriptExample takes nothing returns nothing
local group groupname = CreateGroup()
call GroupEnumUnitsInRange(groupname, X, Y, radius, Condition(function ThatContainsUnitTypeChecks))
call ForGroup(groupname, function actions)
call DestroyGroup(groupname)
set groupname = null
endfunction[/code]
What is wrong with this? Do the ForGroup or DestroyGroup natives work too fast for GroupEnum?

EDIT: By the way I hope I don't need to say "Don't be afraid to answer?":grin:
~Thanks for your time
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
It works just fine for me...

Try printing a message containing the number of units in groupname, then check if it's the same as what you're expecting?

A possible sollution might be removing the ForGroup function and making a custom loop ala
JASS:
loop
    set unit = FirstOfGroup(groupname)
    exitwhen unit = null
    call GroupRemoveUnit(unit, groupname) // not sure if this is the correct name of the function
    // Do stuff with the unit
endloop
 
Status
Not open for further replies.
Top