so I decided to learn Jass finally

Reaction score
333
Will that execute the function 'group_stuff'?

Yes, but the function will be executed as a group filter, which means it must return a boolean (use false in this case) and you must use GetFilterUnit() instead of GetEnumUnit().
 

Vestras

Retired
Reaction score
248
Negative. Filter(...) is a conditions, so that function would be a conditions, for example if I wanted enemy units in the group.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
An alternative is the FirstOfGroup() loop.
JASS:
function Substitute takes nothing returns boolean
    return true
endfunction

function blablabla...

local group g = CreateGroup()
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local unit u

call GroupEnumUnitsInRange(g, x, y, AoE, Condition(function Substitute))

loop
    set u = FirstOfGroup(g)
    exitwhen u == null
    if IsUnitAlly(u, GetOwningPlayer(caster)) == true and IsUnitType(u, UNIT_TYPE_STRUCTURE) != true and GetWidgetLife(u) > .405 then
        //Do your actions
    endif
    call GroupRemoveUnit(g, u)
endloop
 
Reaction score
333
I suggest just using the GroupEnum filter function. ForGroup and FirstOfGroup loops are unnecessary in this situation.
 

Flare

Stops copies me!
Reaction score
662
Hmmm, just noticed this
Code:
set hlife = 0
set glife = 0
set gx = 0
set gy = 0

You don't need to do that

1) You're always setting the value of the variable before using it, so it doesn't really matter

2) Since those are local, each time the function runs, a new instance of that variable is generated (and it starts out completely blank) so there's no problem with the variables having incorrect values unless you specifically give it the wrong value :p
 

Romek

Super Moderator
Reaction score
963
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