• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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.
 
Level 8
Joined
Jul 10, 2008
Messages
353
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.
Top