HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Passing data to groups?

08-10-2008, 10:04 AM#1
Vestras
I want to pass my struct data to groups (and I don't want to have a global struct array), now, I use HAIL, and I was wondering if you could it like this;

Collapse JASS:
local MyData d=GetData(whichGroup)

Because that function takes a handle. Now, if I could, which group would I use?
08-10-2008, 10:41 AM#2
TheDamien
Erm? The group you attached to?

If you mean that you want to pass data to callbacks like ForGroup, then use globals.
08-10-2008, 10:48 AM#3
Vestras
Quote:
Originally Posted by TheDamien
Erm? The group you attached to?

If you mean that you want to pass data to callbacks like ForGroup, then use globals.

Yeah, but if I should use a function?
08-10-2008, 10:56 AM#4
TheDamien
I do not understand. You can not acquire the group in an Enum or ForGroup function (or at the very least I have never heard of a way), and even if there was such a way it would be slow and roundabout to pass the data using attachment.

So use globals.
08-10-2008, 11:04 AM#5
DioD
local struct A = MyStructCreate()

A is INTEGER - struct handle

then attach struct handle to group via handle vars (return bug + cache)
08-10-2008, 11:06 AM#6
cohadar
Use global struct variable:

Collapse JASS:
struct Data
  //...
endstruct

globals
    private Data arg_data
endglobals

private function Enum takes nothing returns nothing
    if IsUnitAlly(arg_data.caster, GetOwningPlayer(GetEnumUnit())) then
    //......
endfunction

private function Actions takes nothing returns nothing
    local Data data = Data.create()
    //...
    call GroupEnumUnitsInRange(g, AOE, null)
    set arg_data = data // set global struct variable before calling ForGroup
    call ForGroup(g, function Enum)
endfunction
08-10-2008, 11:06 AM#7
Anitarf
I don't understand what application this could be used for either. If we're talking about ForGroup loops, then as others have pointed out use a global variable.