• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[JASS] GroupAddGroup, or HOW to COPY a Group ?!?!

Status
Not open for further replies.
Level 8
Joined
Jul 10, 2008
Messages
353
I have wasted 2 days and I still have no clue what am doing wrong. Please someone help.
My attempt:

JASS:
//WSgroups is global group array

local integer j=1
local group array g
loop
            exitwhen j>8
              if CountUnitsInGroup(WSgroups[j])>0 then
                call GroupAddGroup(WSgroups[j],g[j]) //also i have tried GroupAddGroup(g[j],WSgroups[j])
                call MyDisplay("g[j]: "+I2S(j)+" "+I2S(CountUnitsInGroup(g[j]))) //this display 0
                loop
                    set u=FirstOfGroup(g[j])
                    exitwhen u==null
                    set gUAI=gUAI+1 //this displays 0 at the end of loop
                    set LocArrayX[gUAI]=GetUnitX(u)
                    set LocArrayY[gUAI]=GetUnitY(u)
                    set g6UnitArray[gUAI]=u
                    call GroupRemoveUnit(g[j],u)
                endloop
                call KillGroup(g[j])
            endif
            set j=j+1
endloop
call MyDisplay("unit number: "+I2S(gUAI))  //displays 0
Result g[j] is empty and gUAI returns 0


Am really pissed at this, I want to COPY a group into another, so i will have same units in 2 different groups, is this impossible?
 
Last edited:
The coding style is still same as it was in here [code=jass] - Simple trigger, high leak. Help pls..
Please read my advice in the linked thread again. Such function like these:

JASS:
function AddToGroup takes nothing returns nothing
        call GroupAddUnit(groups006b[jg],GetEnumUnit())
endfunction

is really just random and senseless.

For your task, there is already a function for it:

function GroupAddGroup takes group sourceGroup, group destGroup returns nothing

You can read it up in the function list and also see what it does inside.
 
The coding style is still same as it was in here [code=jass] - Simple trigger, high leak. Help pls..
Please read my advice in the linked thread again. Such function like these:

JASS:
function AddToGroup takes nothing returns nothing
        call GroupAddUnit(groups006b[jg],GetEnumUnit())
endfunction

is really just random and senseless.

For your task, there is already a function for it:

function GroupAddGroup takes group sourceGroup, group destGroup returns nothing

You can read it up in the function list and also see what it does inside.
And to think I event posted to the title the GroupAddGroup. Can you, for a change, answer a question directly?

I tried that! I really don't know what am doing wrong >.<
Also GroupAddGroup adds group1 to group2 or group2 to group1? and does it maintains both groups? So at the end i have group1 and group2 I can use? (i tried adding groups006 to g and g to groups006, but same results) :/

here, I deleted attempt 1, and left only attempt 2, can you tell me what am doing wrong on the attempt posted in op? (its 2 simple super common loops.)

edit: I forgot to CreateGroup() for the group array
 
Last edited:
Status
Not open for further replies.
Back
Top