self explanotary pretty much
JASS:
library IsGroupEmpty /* by edo494 version 1.1
*
* This function takes group and checks if it is empty.
*
*===========================================================
*
* ChangeLog:
*
* 1.0 - Intial Release
*
* 1.1 - Updated a little bit
*
*===========================================================
*
* API:
*
* function IsGroupEmpty takes group whichgroup returns boolean
*
*===========================================================
*/
private struct IsGroupEmptys extends array
static group gr
static method CallBack takes nothing returns nothing
call GroupAddUnit(IsGroupEmptys.gr, GetEnumUnit())
endmethod
static method IsGEm takes group whichgroup returns boolean
local unit u
set IsGroupEmptys.gr = CreateGroup()
call ForGroup(whichgroup, function thistype.CallBack)
loop
set u = FirstOfGroup(IsGroupEmptys.gr)
if not( u == null ) and not IsUnitType(u, UNIT_TYPE_DEAD) then
set u = null
call DestroyGroup(IsGroupEmptys.gr)
return false
endif
exitwhen u == null
endloop
call DestroyGroup(IsGroupEmptys.gr)
return true
endmethod
endstruct
function IsGroupEmpty takes group whichgroup returns boolean
return IsGroupEmptys.IsGEm(whichgroup)
endfunction
endlibrary
JASS:
scope ATest
private function F_Test takes nothing returns boolean
local group g = CreateGroup()
call GroupEnumUnitsOfPlayer(g, Player(0), null)
if not IsGroupEmpty(g) then
call BJDebugMsg("Filled")
else
call BJDebugMsg("Empty")
endif
if not IsGroupEmpty(g) then
call BJDebugMsg("Filled")
else
call BJDebugMsg("Empty")
endif
call GroupClear(g)
if not IsGroupEmpty(g) then
call BJDebugMsg("Filled")
else
call BJDebugMsg("Empty")
endif
call DestroyGroup(g)
set g = null
return false
endfunction
private module INIT
private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0., false)
call TriggerAddCondition(t, Condition(function F_Test))
set t = null
endmethod
endmodule
private struct INITI
implement INIT
endstruct
endscope
Last edited: