• 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] Group = Group == Copy or pointer...

Status
Not open for further replies.
Level 8
Joined
Jul 23, 2005
Messages
329
Let's say I have two group variables,
JASS:
local group GroupA
local group GroupB
Now I'll set one of them to a new group. add some units, then set Group B to Group A...
JASS:
 set GroupA = CreateGroup() 
call GroupAddUnit(GroupA,Whatever)
//---snip---
set GroupB = GroupA

OK: What will happen if I edit group B? Will GroupA Also be affected (As they would if they were C pointers?)?
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
If you're enuming anyways it's faster to just add it as the loop goes through.

Eg:

JASS:
local group g = CreateGroup()
local group g2 = CreateGroup()
local unit u
//enum for g
loop
    set u = FirstOfGroup(g)
    exitwhen u == null
    call GroupAddUnit(g2,u)
    call GroupRemoveUnit(g,u)
    //do other stuff you would do in the loop
endloop
 
Status
Not open for further replies.
Top