Compute(<>)
New Member
- Reaction score
- 1
Hi there this is my first snippet
Hope you like it
Requires
JNGP
Info: This snippet returns a unit for the group so its like FirstOfGroup() but can return and unit. So if you want the ThirdOfGroup you would do this
GetUnitofGroup(3,whichGroup, fasle) easy.
Please comment on what is bad and could be improved.
v1.00 - Released
Hope you like it
Requires
JNGP
Info: This snippet returns a unit for the group so its like FirstOfGroup() but can return and unit. So if you want the ThirdOfGroup you would do this
GetUnitofGroup(3,whichGroup, fasle) easy.
JASS:
library Group
globals
private unit array u
private unit array u2
private group g = CreateGroup()
endglobals
function GetUnitofGroup takes integer i, group grp, boolean Remove returns unit
local integer h = i
if i != 1 then
loop
exitwhen h == 0
set h = h - 1
set u[h] = FirstOfGroup(grp)
call GroupRemoveUnit( grp, u[h])
call GroupAddUnit( g, u[h])
endloop
set h = i
loop
exitwhen h == 0
set h = h - 1
set u2[h] = FirstOfGroup(g)
call GroupRemoveUnit( g, u2[h])
call GroupAddUnit( grp, u2[h])
endloop
if Remove == true then
call GroupRemoveUnit( grp, u[0])
endif
return u[0]
else
set u[0] = FirstOfGroup(grp)
if Remove == true then
call GroupRemoveUnit( grp, u[0])
endif
return u[0]
endif
endfunction
endlibrary
Please comment on what is bad and could be improved.
v1.00 - Released