• 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.
  • Vote for the theme of Hive's HD Modeling Contest #7! Click here to vote! - Please only vote if you plan on participating❗️

Is IsUnitGroupEmptyBJ a good BJ?

Status
Not open for further replies.
Level 3
Joined
Sep 9, 2009
Messages
658
Is IsUnitGroupEmptyBJ a good BJ? I looked at it and it seemed fine to me although I can't really be sure since it's a BJ that calls another BJ.

Anyway, I'm using it for a spell because apparently, an empty group does not equate to null.

JASS:
if g != null then
    blah blah actions
else
    call PauseTimer(t)
    call DestroyTimer(t)
endif

The else actions don't fire when I'm 100% sure the group is empty. So I can only conclude that an empty group is not equal to a null group. So I think I'll use IsUnitGroupEmptyBJ if it's not a bad function.
 
Well, it iterates through given group, and the enum function will set a boolean to false if it will be called.
So after the group enumeration you can use this boolean as reference, if group is empty or not.

If a group exists, it won't equal null. And if a group is null it does not mean that it's empty.

You can try following, to check if the first unit in this group equals null.

if (FirstOfGroup(g) != null)
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
if (FirstOfGroup(g) != null)
Removed units leave bad references (which aren't null as far as I remember), even within a group's list, so that solution wouldn't be nice if it was used to test a group that needs to hold units for an indefinite amount of time.

It's good though if you're gonna use it for temporary enumeration group lists though.
 
Level 3
Joined
Sep 9, 2009
Messages
658
Well, it iterates through given group, and the enum function will set a boolean to false if it will be called.
So after the group enumeration you can use this boolean as reference, if group is empty or not.

If a group exists, it won't equal null. And if a group is null it does not mean that it's empty.

You can try following, to check if the first unit in this group equals null.

if (FirstOfGroup(g) != null)

On the chance that if (FirstOfGroup(g) != null) doesn't work, how do I use the boolean as reference?

EDIT: It works! Thanks! ;D

Now on a really different topic. How do I make it so that the map shows red floating text when I damage an enemy unit and blue when an enemy unit damages me?
 
Status
Not open for further replies.
Top