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

Question about leak

Status
Not open for further replies.
Level 12
Joined
Nov 3, 2013
Messages
989
  • Trigger
    • Events
    • Conditions
    • Actions
      • For each (Integer Temp_Int[0]) from 1 to SomeVar, do (Actions)
        • Loop - Actions
          • Set Some_UnitGroup[Temp_Int[0]] = (Units in SomeRegion[Temp_Int[0]])
          • Unit Group - Pick every unit in Some_UnitGroup[Temp_Int[0]] and do (Actions)
            • Loop - Actions
              • Some Actions
              • Custom script: set bj_wantDestroyGroup = true
Would set "bj_wantDestroyGroup = true" remove "Some_UnitGroup" even though it was made before the loop?

Don't really know why you wouldn't just call destroy group but I were just wondering.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Setting it to true has to be done before using the group, while if you want to use DestroyGroup you'll have to set it to a variable earlier.

Pick every unit in... is this:

JASS:
function ForGroupBJ takes group whichGroup, code callback returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    call ForGroup(whichGroup, callback)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(whichGroup)
    endif
endfunction
 
Status
Not open for further replies.
Top