ways to attach a struct and use it in a condition function?

waaaks!

Zinctified
Reaction score
255
I'm having problems on how to attach a struct to something and retrieve the struct in a condition function from a GroupEnum filter function

JASS:
function filt takes nothing returns boolean
    local myStruct d = ?? // how will I retrieve myStruct?
    local unit u = GetFilterUnit()
    call UnitDamageTarget(d.c,u,40,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
    return false //The Group will not be filled because the function returns false, instead this function will loop through the units
endfunction

function  bla takes nothing returns nothing
    local group g = NewGroup()
    local myStruct d = myStruct.create()
    local real x = 0.0
    local real y = 0.0
    set d.c = GetTriggerUnit()
    call GroupEnumUnitsInRange(g,x,y,500,Condition(function filt))
    //cleanups.....
endfunction
 

Viikuna

No Marlo no game.
Reaction score
265
That is correct

edit. Example:

JASS:

// in myStruct:
static myStruct temp 

//:
function filt takes nothing returns boolean
    local myStruct d = myStruct.temp
    local unit u = GetFilterUnit()
    call UnitDamageTarget(d.c,u,40,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
    return false //The Group will not be filled because the function returns false, instead this function will loop through the units
endfunction

function  bla takes nothing returns nothing
    local real x = 0.0
    local real y = 0.0
    set myStruct.temp = myStruct.create()
    set myStruct.temp.c = GetTriggerUnit()
    call GroupEnumUnitsInRange(NewGroup(),x,y,500,Condition(function filt))
    //cleanups.....
endfunction
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
how about this:

JASS:
globals
     integer TEMPINT
endglobals

function filt takes nothing returns boolean
    local myStruct d = TEMPINT // retrieve
    local unit u = GetFilterUnit()
    call UnitDamageTarget(d.c,u,40,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
    return false //The Group will not be filled because the function returns false, instead this function will loop through the units
endfunction

function  bla takes nothing returns nothing
    local group g = NewGroup()
    local myStruct d = myStruct.create()
    local real x = 0.0
    local real y = 0.0
    set d.c = GetTriggerUnit()
    set TEMPINT = d //for retrieving
    call GroupEnumUnitsInRange(g,x,y,500,Condition(function filt))
    //cleanups.....
endfunction


condition functions can never have wait so that TEMPINT using will not gonna screw anything up :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top