Simple question: GroupEnum and Filters

newtonrox

Member
Reaction score
2
GroupEnumUnitsInRect() needs a boolexpr that is provided by a filter as parameter right?
So, I was wondering what's the difference when you return true or false to the GroupEnumUnitsInRect().

Does the GroupEnum..() only picks the unit when the filter returns true?

To refer to the picked unit of GroupEnum...() do I have to use GetFilterUnit() inside the filter?

And what's the difference between using Filter(function filter) and Condition(function filter) as a boolexpr for GroupEnum...() ?
 

Artificial

Without Intelligence
Reaction score
326
> GroupEnumUnitsInRect() needs a boolexpr that is provided by a filter as parameter right?
You could also provide [ljass]null[/ljass] as the argument, but doing that with GroupEnums causes a leak, so you'd better provide some boolexpr. x)

> Does the GroupEnum..() only picks the unit when the filter returns true?
Yes.

> To refer to the picked unit of GroupEnum...() do I have to use GetFilterUnit() inside the filter?
Yes, but that isn't actually 'picked unit,' but rather 'matching unit' in GUI terms (e.g. "Pick every unit matching ((Matching unit) Is a Unit)..."

'Picked unit,' i.e. [ljass]GetEnumUnit()[/ljass], is what you'd use inside a ForGroup callback.

But anyway, yeah. ^_^

> And what's the difference between using Filter(function filter) and Condition(function filter) as a boolexpr for GroupEnum...() ?
None. They got no difference in any situation. ;p
 

newtonrox

Member
Reaction score
2
thx! ^^

Is there any GroupEnum...()-like function that sets 2 groups? One for the matching unit and another for the Non-matching unit.

or do I always have to call GroupEnumUnitsInRect() 2 times with 2 different filters?
 

Romek

Super Moderator
Reaction score
964
Use a function like this as the filter:
JASS:
function Filter takes nothing returns boolean
   if not (<Your Conditions>) then
      call GroupAddUnit(<The Other Group>, GetFilterUnit())
      return false
   endif
   return true
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top