set bj_wantDestroyGroup = true [What does it do?]

Carl-Fredrik

New Member
Reaction score
51
Hi everyone!!
So.. what I've learned is that if you don't want a unit group to leak, do like this:

Trigger:
  • Actions
    • Set UnitGroup = (Units in (Playable map area))
    • Unit Group - Pick every unit in UnitGroup and do (Actions)
      • Loop - Actions
        • Unit - Change color of (Picked unit) to Red
    • Custom script: call DestroyGroup (udg_UnitGroup)


But then I see people do like this... and I guess the script somehow also prevents leaking?
Trigger:
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
      • Loop - Actions
        • Unit - Change color of (Picked unit) to Red


So which of these two ways are the best? Maybe the first one is better if you want to use the Unit Group many times... but both prevents leaks, right? Or am I totally wrong?

Well, the simple question is, what does this script do?
JASS:

Thanks in advance!

// Carl-Fredrik
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
>what does this script do?
Well, when you change
Trigger:
  • Unit Group - Pick every unit in (Group) and do (Actions)

To JASS, you get
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

Part of that stores bj_wantDestroyGroup in a variable, then destroys the group if bj_wantDestroyGroup is true. That prevents the leak.
 

Carl-Fredrik

New Member
Reaction score
51
>what does this script do?
Well, when you change
Trigger:
  • Unit Group - Pick every unit in (Group) and do (Actions)

To JASS, you get
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

Part of that stores bj_wantDestroyGroup in a variable, then destroys the group if bj_wantDestroyGroup is true. That prevents the leak.

Thanks for the explanation :) I think I understand it quite well now ;)
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
But it won't work with GroupEnumUnitsOfType.
Only Player(0)'s (red) units will be enumed.
It's because how the gui function are made.
I suggest you use a custom script DestroyGroup instead.

Yes it's a revive, but i just wanted to point out this silly thing.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top