diff --git a/Moose Development/Moose/Scheduler.lua b/Moose Development/Moose/Scheduler.lua index a9bfddb62..259933c68 100644 --- a/Moose Development/Moose/Scheduler.lua +++ b/Moose Development/Moose/Scheduler.lua @@ -121,7 +121,7 @@ function SCHEDULER:_Scheduler() self:T( { Status, Result } ) - if Status and ( ( not Result ) or ( Result and Result ~= false ) ) then + if Status and ( ( not Result == nil ) or ( Result and Result ~= false ) ) then if self.Repeat and ( not self.StopSeconds or ( self.StopSeconds and timer.getTime() <= self.StartTime + self.StopSeconds ) ) then timer.scheduleFunction( self._Scheduler, diff --git a/Moose Development/Moose/Set.lua b/Moose Development/Moose/Set.lua index a53439801..cdbaccf58 100644 --- a/Moose Development/Moose/Set.lua +++ b/Moose Development/Moose/Set.lua @@ -275,20 +275,22 @@ end -- end --end ---- Iterators +-- Iterators --- Interate the SET_BASE and call an interator function for the given set, providing the Object for each element within the set and optional parameters. -- @param #SET_BASE self -- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_BASE. -- @return #SET_BASE self -function SET_BASE:ForEach( IteratorFunction, arg, Set ) +function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArguments ) self:F3( arg ) local function CoRoutine() local Count = 0 for ObjectID, Object in pairs( Set ) do self:T2( Object ) - IteratorFunction( Object, unpack( arg ) ) + if Function( unpack( FunctionArguments ), Object ) == true then + IteratorFunction( Object, unpack( arg ) ) + end Count = Count + 1 if Count % 10 == 0 then coroutine.yield( false ) @@ -314,7 +316,7 @@ function SET_BASE:ForEach( IteratorFunction, arg, Set ) return false end - local Scheduler = SCHEDULER:New( self, Schedule, {}, 0.001, 30, 0 ) + local Scheduler = SCHEDULER:New( self, Schedule, {}, 0.001, 0.001, 0 ) return self end @@ -556,7 +558,7 @@ function SET_GROUP:FindInDatabase( Event ) return Event.IniDCSGroupName, self.Database[Event.IniDCSGroupName] end ---- Interate the SET_GROUP and call an interator function for each **alive** GROUP, providing the GROUP and optional parameters. +--- Iterate the SET_GROUP and call an iterator function for each **alive** GROUP, providing the GROUP and optional parameters. -- @param #SET_GROUP self -- @param #function IteratorFunction The function that will be called when there is an alive GROUP in the SET_GROUP. The function needs to accept a GROUP parameter. -- @return #SET_GROUP self @@ -568,6 +570,72 @@ function SET_GROUP:ForEachGroup( IteratorFunction, ... ) return self end +--- Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence completely in a @{Zone}, providing the GROUP and optional parameters to the called function. +-- @param #SET_GROUP self +-- @param Zone#ZONE ZoneObject The Zone to be tested for. +-- @param #function IteratorFunction The function that will be called when there is an alive GROUP in the SET_GROUP. The function needs to accept a GROUP parameter. +-- @return #SET_GROUP self +function SET_GROUP:ForEachGroupCompletelyInZone( ZoneObject, IteratorFunction, ... ) + self:F2( arg ) + + self:ForEach( IteratorFunction, arg, self.Set, + --- @param Zone#ZONE_BASE ZoneObject + -- @param Group#GROUP GroupObject + function( ZoneObject, GroupObject ) + if GroupObject:IsCompletelyInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) + + return self +end + +--- Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence partly in a @{Zone}, providing the GROUP and optional parameters to the called function. +-- @param #SET_GROUP self +-- @param Zone#ZONE ZoneObject The Zone to be tested for. +-- @param #function IteratorFunction The function that will be called when there is an alive GROUP in the SET_GROUP. The function needs to accept a GROUP parameter. +-- @return #SET_GROUP self +function SET_GROUP:ForEachGroupPartlyInZone( ZoneObject, IteratorFunction, ... ) + self:F2( arg ) + + self:ForEach( IteratorFunction, arg, self.Set, + --- @param Zone#ZONE_BASE ZoneObject + -- @param Group#GROUP GroupObject + function( ZoneObject, GroupObject ) + if GroupObject:IsPartlyInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) + + return self +end + +--- Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence not in a @{Zone}, providing the GROUP and optional parameters to the called function. +-- @param #SET_GROUP self +-- @param Zone#ZONE ZoneObject The Zone to be tested for. +-- @param #function IteratorFunction The function that will be called when there is an alive GROUP in the SET_GROUP. The function needs to accept a GROUP parameter. +-- @return #SET_GROUP self +function SET_GROUP:ForEachGroupNotInZone( ZoneObject, IteratorFunction, ... ) + self:F2( arg ) + + self:ForEach( IteratorFunction, arg, self.Set, + --- @param Zone#ZONE_BASE ZoneObject + -- @param Group#GROUP GroupObject + function( ZoneObject, GroupObject ) + if GroupObject:IsNotInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) + + return self +end + ----- Interate the SET_GROUP and call an interator function for each **alive** player, providing the Group of the player and optional parameters. ---- @param #SET_GROUP self diff --git a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua index 38b7874f7..e6cba3207 100644 --- a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua +++ b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20160606_2213' ) +env.info( 'Moose Generation Timestamp: 20160607_0904' ) local base = _G env.info("Loading MOOSE " .. base.timer.getAbsTime() ) diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index 38b7874f7..e6cba3207 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20160606_2213' ) +env.info( 'Moose Generation Timestamp: 20160607_0904' ) local base = _G env.info("Loading MOOSE " .. base.timer.getAbsTime() ) diff --git a/Moose Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz b/Moose Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz index 78130e686..8eb387d1c 100644 Binary files a/Moose Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz and b/Moose Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz differ diff --git a/Moose Test Missions/Moose_Test_DATABASE/Moose_Test_DATABASE.miz b/Moose Test Missions/Moose_Test_DATABASE/Moose_Test_DATABASE.miz index 57b6fb60e..79b168487 100644 Binary files a/Moose Test Missions/Moose_Test_DATABASE/Moose_Test_DATABASE.miz and b/Moose Test Missions/Moose_Test_DATABASE/Moose_Test_DATABASE.miz differ diff --git a/Moose Test Missions/Moose_Test_DESTROY/MOOSE_Test_DESTROY.miz b/Moose Test Missions/Moose_Test_DESTROY/MOOSE_Test_DESTROY.miz index 607efc496..ef46fca27 100644 Binary files a/Moose Test Missions/Moose_Test_DESTROY/MOOSE_Test_DESTROY.miz and b/Moose Test Missions/Moose_Test_DESTROY/MOOSE_Test_DESTROY.miz differ diff --git a/Moose Test Missions/Moose_Test_ESCORT/MOOSE_Test_ESCORT.miz b/Moose Test Missions/Moose_Test_ESCORT/MOOSE_Test_ESCORT.miz index fd4820a94..e28087d0f 100644 Binary files a/Moose Test Missions/Moose_Test_ESCORT/MOOSE_Test_ESCORT.miz and b/Moose Test Missions/Moose_Test_ESCORT/MOOSE_Test_ESCORT.miz differ diff --git a/Moose Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz b/Moose Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz index 7919f2a9a..5f7f0a6ae 100644 Binary files a/Moose Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz and b/Moose Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz differ diff --git a/Moose Test Missions/Moose_Test_SEAD/MOOSE_Test_SEAD.miz b/Moose Test Missions/Moose_Test_SEAD/MOOSE_Test_SEAD.miz index da14ebee1..f9d1a7598 100644 Binary files a/Moose Test Missions/Moose_Test_SEAD/MOOSE_Test_SEAD.miz and b/Moose Test Missions/Moose_Test_SEAD/MOOSE_Test_SEAD.miz differ diff --git a/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.lua b/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.lua index 95cf653bd..46f65e112 100644 --- a/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.lua +++ b/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.lua @@ -38,6 +38,26 @@ for i = 1, 30 do GroupSAM_AttackVehicle = SpawnSAM_AttackVehicle:SpawnInZone( ZONE:New("Spawn Zone"), true) end +SetVehicleCompletely = SET_GROUP:New() + :FilterPrefixes( "Spawn Vehicle Zone Completely" ) + :FilterStart() + +SetVehiclePartly = SET_GROUP:New() + :FilterPrefixes( "Spawn Vehicle Zone Partly" ) + :FilterStart() + +SetVehicleNot = SET_GROUP:New() + :FilterPrefixes( "Spawn Vehicle Zone Not" ) + :FilterStart() + +Spawn_Vehicle_Zone_Completely = SPAWN:New( 'Spawn Vehicle Zone Completely' ) +Spawn_Vehicle_Zone_Partly = SPAWN:New( 'Spawn Vehicle Zone Partly' ) +Spawn_Vehicle_Zone_Not = SPAWN:New( 'Spawn Vehicle Zone Not' ) +for i = 1, 30 do + Spawn_Vehicle_Zone_Completely:SpawnInZone( ZONE:New("Spawn Zone Completely"), true) + Spawn_Vehicle_Zone_Partly:SpawnInZone( ZONE:New("Spawn Zone Partly"), true) + Spawn_Vehicle_Zone_Not:SpawnInZone( ZONE:New("Spawn Zone Not"), true) +end --DBBlue:TraceDatabase() --SCHEDULER:New( DBBluePlanes, DBBluePlanes.Flush, { }, 1 ) @@ -79,5 +99,42 @@ SetSAMGroup:ForEachGroup( end end ) + +GroupZoneCompletely = GROUP:FindByName( "Zone Completely" ) +GroupZonePartly = GROUP:FindByName( "Zone Partly" ) +GroupZoneNot = GROUP:FindByName( "Zone Not" ) + +ZoneCompletely = ZONE_POLYGON:New( "Zone Completely", GroupZoneCompletely ):SmokeZone( POINT_VEC3.SmokeColor.White ) +ZonePartly = ZONE_POLYGON:New( "Zone Partly", GroupZonePartly ):SmokeZone( POINT_VEC3.SmokeColor.White ) +ZoneNot = ZONE_POLYGON:New( "Zone Not", GroupZoneNot ):SmokeZone( POINT_VEC3.SmokeColor.White ) + +SetVehicleCompletely:ForEachGroupCompletelyInZone( ZoneCompletely, + --- @param Group#GROUP MooseGroup + function( MooseGroup ) + for UnitId, UnitData in pairs( MooseGroup:GetUnits() ) do + local UnitAction = UnitData -- Unit#UNIT + UnitAction:SmokeBlue() + end + end +) - +SetVehiclePartly:ForEachGroupPartlyInZone( ZonePartly, + --- @param Group#GROUP MooseGroup + function( MooseGroup ) + for UnitId, UnitData in pairs( MooseGroup:GetUnits() ) do + local UnitAction = UnitData -- Unit#UNIT + UnitAction:SmokeBlue() + end + end +) + +SetVehicleNot:ForEachGroupNotInZone( ZoneNot, + --- @param Group#GROUP MooseGroup + function( MooseGroup ) + for UnitId, UnitData in pairs( MooseGroup:GetUnits() ) do + local UnitAction = UnitData -- Unit#UNIT + UnitAction:SmokeBlue() + end + end +) + \ No newline at end of file diff --git a/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.miz b/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.miz index abf1787dd..e51cf1dc4 100644 Binary files a/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.miz and b/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.miz differ diff --git a/Moose Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz b/Moose Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz index 3bc9b43b6..62a44e667 100644 Binary files a/Moose Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz and b/Moose Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz differ diff --git a/Moose Test Missions/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz b/Moose Test Missions/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz index f1b54e0d0..609f433c1 100644 Binary files a/Moose Test Missions/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz and b/Moose Test Missions/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz differ diff --git a/Moose Test Missions/Moose_Test_TASK_Pickup_and_Deploy/MOOSE_Test_TASK_Pickup_and_Deploy.miz b/Moose Test Missions/Moose_Test_TASK_Pickup_and_Deploy/MOOSE_Test_TASK_Pickup_and_Deploy.miz index 972d1de60..b1804b4c2 100644 Binary files a/Moose Test Missions/Moose_Test_TASK_Pickup_and_Deploy/MOOSE_Test_TASK_Pickup_and_Deploy.miz and b/Moose Test Missions/Moose_Test_TASK_Pickup_and_Deploy/MOOSE_Test_TASK_Pickup_and_Deploy.miz differ diff --git a/Moose Test Missions/Moose_Test_WRAPPER/Moose_Test_WRAPPER.miz b/Moose Test Missions/Moose_Test_WRAPPER/Moose_Test_WRAPPER.miz index 2544f7ead..26aa76af2 100644 Binary files a/Moose Test Missions/Moose_Test_WRAPPER/Moose_Test_WRAPPER.miz and b/Moose Test Missions/Moose_Test_WRAPPER/Moose_Test_WRAPPER.miz differ diff --git a/Moose Test Missions/Moose_Test_ZONE/Moose_Test_ZONE.miz b/Moose Test Missions/Moose_Test_ZONE/Moose_Test_ZONE.miz index 3d4514e37..423897edf 100644 Binary files a/Moose Test Missions/Moose_Test_ZONE/Moose_Test_ZONE.miz and b/Moose Test Missions/Moose_Test_ZONE/Moose_Test_ZONE.miz differ diff --git a/Moose Test Missions/Moose_Test_ZONE_POLYGON/Moose_Test_ZONE_POLYGON.miz b/Moose Test Missions/Moose_Test_ZONE_POLYGON/Moose_Test_ZONE_POLYGON.miz index cf90132d6..a37bf578e 100644 Binary files a/Moose Test Missions/Moose_Test_ZONE_POLYGON/Moose_Test_ZONE_POLYGON.miz and b/Moose Test Missions/Moose_Test_ZONE_POLYGON/Moose_Test_ZONE_POLYGON.miz differ diff --git a/Moose Test Missions/Moose_Test_ZONE_RADIUS/Moose_Test_ZONE_RADIUS.miz b/Moose Test Missions/Moose_Test_ZONE_RADIUS/Moose_Test_ZONE_RADIUS.miz index f85563c32..0b15cff4a 100644 Binary files a/Moose Test Missions/Moose_Test_ZONE_RADIUS/Moose_Test_ZONE_RADIUS.miz and b/Moose Test Missions/Moose_Test_ZONE_RADIUS/Moose_Test_ZONE_RADIUS.miz differ diff --git a/Moose Test Missions/Moose_Test_ZONE_UNIT/Moose_Test_ZONE_UNIT.miz b/Moose Test Missions/Moose_Test_ZONE_UNIT/Moose_Test_ZONE_UNIT.miz index 59ee818cb..22d02ffd1 100644 Binary files a/Moose Test Missions/Moose_Test_ZONE_UNIT/Moose_Test_ZONE_UNIT.miz and b/Moose Test Missions/Moose_Test_ZONE_UNIT/Moose_Test_ZONE_UNIT.miz differ diff --git a/Moose Training/Documentation/Set.html b/Moose Training/Documentation/Set.html index eace60dc4..d94bbe619 100644 --- a/Moose Training/Documentation/Set.html +++ b/Moose Training/Documentation/Set.html @@ -200,7 +200,7 @@ The following iterator methods are currently available within the SETUNIT:<
| SET | +SET_BASE | @@ -218,76 +218,76 @@ The following iterator methods are currently available within the SETUNIT:< |
SETSET_BASE| SET.ClassName | +SET_BASE.ClassName | |
| SET.Database | +SET_BASE.Database | |
| SET:Flush() | +SET_BASE:Flush() |
- Flushes the current SET contents in the log ... +Flushes the current SET_BASE contents in the log ... |
| SET:ForEach(IteratorFunction, arg, Set) | +SET_BASE:ForEach(IteratorFunction, arg, Set) |
- Interate the SET and call an interator function for the given set, providing the Object for each element within the set and optional parameters. +Interate the SET_BASE and call an interator function for the given set, providing the Object for each element within the set and optional parameters. |
| SET:IsIncludeObject(Object) | +SET_BASE:IsIncludeObject(Object) |
Decides whether to include the Object |
| SET:New(Database) | +SET_BASE:New(Database) |
- Creates a new SET object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names. +Creates a new SET_BASE object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names. |
| SET.Set | +SET_BASE.Set | |
| SET:_Add(ObjectName, Object) | +SET_BASE:_Add(ObjectName, Object) |
Adds a Object based on the Object Name. |
| SET:_EventOnBirth(Event) | +SET_BASE:_EventOnBirth(Event) |
Handles the OnBirth event for the Set. |
| SET:_EventOnDeadOrCrash(Event) | +SET_BASE:_EventOnDeadOrCrash(Event) |
Handles the OnDead or OnCrash event for alive units set. |
| SET:_FilterStart() | +SET_BASE:_FilterStart() |
Starts the filtering for the defined collection. |
| SET:_Find(ObjectName) | +SET_BASE:_Find(ObjectName) |
Finds an Object based on the Object Name. |
@@ -486,9 +486,9 @@ The following iterator methods are currently available within the SETUNIT:<