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

Set bj_wantDestroyGroup = true

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
Simple question. Why is this trigger bad?

  • Custom script: set bj_wantDestroyGroup = true
According to this thread: http://www.thehelper.net/threads/custom-script-set-bj_wantdestroygroup-true.132841/

They do the same thing and are equally efficient, only difference being that bj
is easier to implement. But I hear tonnes of people saying to stay away from them,
or dont use them too often and set the group then destroy instead. Why?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
You may be confusing BJ's with each other.
In general, a BJ is bad, but a bj isn't.

The lower-case bj is just a prefix of a variable (like bj_lastCreatedUnit, which is just a unit variable).
There is nothing wrong with these variables and there's no reason not to use them.

The upper-case BJ is a function. In GUI, it would be something like "Unit - Create Units facing angle".
When you convert this to JASS, it becomes a stupid function
JASS:
function CreateNUnitsAtLoc takes integer count, integer unitId, player whichPlayer, location loc, real face returns group
    call GroupClear(bj_lastCreatedGroup)
    loop
        set count = count - 1
        exitwhen count < 0
        call CreateUnitAtLocSaveLast(whichPlayer, unitId, loc, face)
        call GroupAddUnit(bj_lastCreatedGroup, bj_lastCreatedUnit)
    endloop
    return bj_lastCreatedGroup
endfunction
Most of the GUI-functions are BJ's like this (some bigger, some smaller).
They're bad because it can usually be done in a much simpler way that requires less operations.


Conclusion: nothing wrong with bj_wantDestroyGroup. It's a boolean variable and you can use it whenever you want.
When using JASS, stay away from BJ functions though (in JNGP these are colored in red by default).

I hope that answers your question.
 
Status
Not open for further replies.
Top