• 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.

[JASS] groups on globals

Status
Not open for further replies.
Level 20
Joined
Aug 13, 2013
Messages
1,696
you can destroy or null it if you set it in some functions. You can't destroy,remove or null inside the global block.

EDIT:

Set the global group in Init like: set g = CreateGroup ( ) and use it but don't destroy it, set it in INIT Function in your trigger

EDIT2:

If you destroy the global group while you set it in Init Function of your trigger and you set it once, of course the group will be erased and will not work because you only set it once in the trigger but If you'd set it every execution of the trigger then well destroy it.

EDIT3:
Example:
JASS:
globals
private group g
endglobals

private function Action takes nothing returns nothing
    set g = CreateGroup ( ) // You'd set it every action execution.
    call GroupEnumUnitsInRange.....() b // just as an example of using the group
    call DestroyGroup ( g ) // will work
    set g = null // Will work
endfunction

JASS:
globals
private group g
endglobals

private function Action takes nothing returns nothing
    call GroupEnumUnitsInRange.....( g ) // WILL NOT WORK ANYMORE BECAUSE YOU ALREADY DESTROY THE GROUP
endfunction

private function Init takes nothing returns nothing
     local trigger t = CreateTrigger ( )
     call TrigggerAddAction.....()
     set g = CreateGroup ( ) // You'd set it in INIT Function
     call DestroyGroup ( g ) // You destroy it in Init Function, Of course this will work
     set g = null // You null it in Init Function, Of course this will work
endfunction
 
Does group on globals leak? coz i cant destroy it...

JASS:
globals
     private group g
endglobals

a group variable, like a unit variable, is just a pointer to an object. If you use set g=CreateGroup() and never destroy it, it will leak! That being said, if you use the ONE group statically across your map, it might not be so bad that it leaks.


Just avoid using set g=CreateGroup() before you've destroyed an existing one.
 
Level 2
Joined
Apr 13, 2008
Messages
13
okay..

so if a specific hero is not picked, his specific ability is not used... therefore it will leak

thanks everyone
 
Status
Not open for further replies.
Top