diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index c0565afc9..9fdd5f659 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -254,7 +254,7 @@ do -- COORDINATE --- Create a new COORDINATE object from Vec2 coordinates. -- @param #COORDINATE self -- @param DCS#Vec2 Vec2 The Vec2 point. - -- @param DCS#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height. + -- @param DCS#Distance LandHeightAdd (Optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height. -- @return #COORDINATE function COORDINATE:NewFromVec2( Vec2, LandHeightAdd ) @@ -536,10 +536,10 @@ do -- COORDINATE -- @param #COORDINATE self -- @param DCS#Distance Distance The Distance to be added in meters. -- @param DCS#Angle Angle The Angle in degrees. Defaults to 0 if not specified (nil). - -- @param #boolean Keepalt If true, keep altitude of original coordinate. Default is that the new coordinate is created at the translated land height. + -- @param #boolean KeepAltitude If true, keep altitude of original coordinate. Default is that the new coordinate is created at the translated land height. -- @param #boolean Overwrite If true, overwrite the original COORDINATE with the translated one. Otherwise, create a new COORDINATE. -- @return #COORDINATE The new calculated COORDINATE. - function COORDINATE:Translate( Distance, Angle, Keepalt, Overwrite ) + function COORDINATE:Translate( Distance, Angle, KeepAltitude, Overwrite ) -- Angle in rad. local alpha = math.rad( (Angle or 0) ) @@ -547,7 +547,7 @@ do -- COORDINATE local x = Distance * math.cos( alpha ) + self.x -- New x local z = Distance * math.sin( alpha ) + self.z -- New z - local y = Keepalt and self.y or land.getHeight( { x = x, y = z } ) + local y = KeepAltitude and self.y or land.getHeight( { x = x, y = z } ) if Overwrite then self.x = x @@ -1725,89 +1725,89 @@ do -- COORDINATE --- Big smoke and fire at the coordinate. -- @param #COORDINATE self -- @param Utilities.Utils#BIGSMOKEPRESET preset Smoke preset (0=small smoke and fire, 1=medium smoke and fire, 2=large smoke and fire, 3=huge smoke and fire, 4=small smoke, 5=medium smoke, 6=large smoke, 7=huge smoke). - -- @param #number density (Optional) Smoke density. Number in [0,...,1]. Default 0.5. - function COORDINATE:BigSmokeAndFire( preset, density ) - self:F2( { preset = preset, density = density } ) - density = density or 0.5 - trigger.action.effectSmokeBig( self:GetVec3(), preset, density ) + -- @param #number Density (Optional) Smoke density. Number in [0,...,1]. Default 0.5. + function COORDINATE:BigSmokeAndFire( Preset, Density ) + self:F2( { Preset = Preset, Density = Density } ) + Density = Density or 0.5 + trigger.action.effectSmokeBig( self:GetVec3(), Preset, Density ) end --- Small smoke and fire at the coordinate. -- @param #COORDINATE self - -- @number density (Optional) Smoke density. Number between 0 and 1. Default 0.5. - function COORDINATE:BigSmokeAndFireSmall( density ) - self:F2( { density = density } ) - density = density or 0.5 - self:BigSmokeAndFire( BIGSMOKEPRESET.SmallSmokeAndFire, density ) + -- @number Density (Optional) Smoke density. Number between 0 and 1. Default 0.5. + function COORDINATE:BigSmokeAndFireSmall( Density ) + self:F2( { Density = Density } ) + Density = Density or 0.5 + self:BigSmokeAndFire( BIGSMOKEPRESET.SmallSmokeAndFire, Density ) end --- Medium smoke and fire at the coordinate. -- @param #COORDINATE self - -- @number density (Optional) Smoke density. Number between 0 and 1. Default 0.5. - function COORDINATE:BigSmokeAndFireMedium( density ) - self:F2( { density = density } ) - density = density or 0.5 - self:BigSmokeAndFire( BIGSMOKEPRESET.MediumSmokeAndFire, density ) + -- @number Density (Optional) Smoke density. Number between 0 and 1. Default 0.5. + function COORDINATE:BigSmokeAndFireMedium( Density ) + self:F2( { Density = Density } ) + Density = Density or 0.5 + self:BigSmokeAndFire( BIGSMOKEPRESET.MediumSmokeAndFire, Density ) end --- Large smoke and fire at the coordinate. -- @param #COORDINATE self - -- @number density (Optional) Smoke density. Number between 0 and 1. Default 0.5. - function COORDINATE:BigSmokeAndFireLarge( density ) - self:F2( { density = density } ) - density = density or 0.5 - self:BigSmokeAndFire( BIGSMOKEPRESET.LargeSmokeAndFire, density ) + -- @number Density (Optional) Smoke density. Number between 0 and 1. Default 0.5. + function COORDINATE:BigSmokeAndFireLarge( Density ) + self:F2( { Density = Density } ) + Density = Density or 0.5 + self:BigSmokeAndFire( BIGSMOKEPRESET.LargeSmokeAndFire, Density ) end --- Huge smoke and fire at the coordinate. -- @param #COORDINATE self - -- @number density (Optional) Smoke density. Number between 0 and 1. Default 0.5. - function COORDINATE:BigSmokeAndFireHuge( density ) - self:F2( { density = density } ) - density = density or 0.5 - self:BigSmokeAndFire( BIGSMOKEPRESET.HugeSmokeAndFire, density ) + -- @number Density (Optional) Smoke density. Number between 0 and 1. Default 0.5. + function COORDINATE:BigSmokeAndFireHuge( Density ) + self:F2( { Density = Density } ) + Density = Density or 0.5 + self:BigSmokeAndFire( BIGSMOKEPRESET.HugeSmokeAndFire, Density ) end --- Small smoke at the coordinate. -- @param #COORDINATE self - -- @number density (Optional) Smoke density. Number between 0 and 1. Default 0.5. - function COORDINATE:BigSmokeSmall( density ) - self:F2( { density = density } ) - density = density or 0.5 - self:BigSmokeAndFire( BIGSMOKEPRESET.SmallSmoke, density ) + -- @number Density (Optional) Smoke density. Number between 0 and 1. Default 0.5. + function COORDINATE:BigSmokeSmall( Density ) + self:F2( { Density = Density } ) + Density = Density or 0.5 + self:BigSmokeAndFire( BIGSMOKEPRESET.SmallSmoke, Density ) end --- Medium smoke at the coordinate. -- @param #COORDINATE self - -- @number density (Optional) Smoke density. Number between 0 and 1. Default 0.5. - function COORDINATE:BigSmokeMedium( density ) - self:F2( { density = density } ) - density = density or 0.5 - self:BigSmokeAndFire( BIGSMOKEPRESET.MediumSmoke, density ) + -- @number Density (Optional) Smoke density. Number between 0 and 1. Default 0.5. + function COORDINATE:BigSmokeMedium( Density ) + self:F2( { Density = Density } ) + Density = Density or 0.5 + self:BigSmokeAndFire( BIGSMOKEPRESET.MediumSmoke, Density ) end --- Large smoke at the coordinate. -- @param #COORDINATE self - -- @number density (Optional) Smoke density. Number between 0 and 1. Default 0.5. - function COORDINATE:BigSmokeLarge( density ) - self:F2( { density = density } ) - density = density or 0.5 - self:BigSmokeAndFire( BIGSMOKEPRESET.LargeSmoke, density ) + -- @number Density (Optional) Smoke density. Number between 0 and 1. Default 0.5. + function COORDINATE:BigSmokeLarge( Density ) + self:F2( { Density = Density } ) + Density = Density or 0.5 + self:BigSmokeAndFire( BIGSMOKEPRESET.LargeSmoke, Density ) end --- Huge smoke at the coordinate. -- @param #COORDINATE self - -- @number density (Optional) Smoke density. Number between 0 and 1. Default 0.5. - function COORDINATE:BigSmokeHuge( density ) - self:F2( { density = density } ) - density = density or 0.5 - self:BigSmokeAndFire( BIGSMOKEPRESET.HugeSmoke, density ) + -- @number Density (Optional) Smoke density. Number between 0 and 1. Default 0.5. + function COORDINATE:BigSmokeHuge( Density ) + self:F2( { Density = Density } ) + Density = Density or 0.5 + self:BigSmokeAndFire( BIGSMOKEPRESET.HugeSmoke, Density ) end --- Flares the point in a color. -- @param #COORDINATE self -- @param Utilities.Utils#FLARECOLOR FlareColor - -- @param DCS#Azimuth Azimuth (optional) The azimuth of the flare direction. The default azimuth is 0. + -- @param DCS#Azimuth Azimuth (Optional) The azimuth of the flare direction. The default azimuth is 0. function COORDINATE:Flare( FlareColor, Azimuth ) self:F2( { FlareColor } ) trigger.action.signalFlare( self:GetVec3(), FlareColor, Azimuth and Azimuth or 0 ) @@ -1815,7 +1815,7 @@ do -- COORDINATE --- Flare the COORDINATE White. -- @param #COORDINATE self - -- @param DCS#Azimuth Azimuth (optional) The azimuth of the flare direction. The default azimuth is 0. + -- @param DCS#Azimuth Azimuth (Optional) The azimuth of the flare direction. The default azimuth is 0. function COORDINATE:FlareWhite( Azimuth ) self:F2( Azimuth ) self:Flare( FLARECOLOR.White, Azimuth ) @@ -1823,7 +1823,7 @@ do -- COORDINATE --- Flare the COORDINATE Yellow. -- @param #COORDINATE self - -- @param DCS#Azimuth Azimuth (optional) The azimuth of the flare direction. The default azimuth is 0. + -- @param DCS#Azimuth Azimuth (Optional) The azimuth of the flare direction. The default azimuth is 0. function COORDINATE:FlareYellow( Azimuth ) self:F2( Azimuth ) self:Flare( FLARECOLOR.Yellow, Azimuth ) @@ -1831,7 +1831,7 @@ do -- COORDINATE --- Flare the COORDINATE Green. -- @param #COORDINATE self - -- @param DCS#Azimuth Azimuth (optional) The azimuth of the flare direction. The default azimuth is 0. + -- @param DCS#Azimuth Azimuth (Optional) The azimuth of the flare direction. The default azimuth is 0. function COORDINATE:FlareGreen( Azimuth ) self:F2( Azimuth ) self:Flare( FLARECOLOR.Green, Azimuth ) @@ -2527,7 +2527,7 @@ do -- COORDINATE --- Return a BR string from a COORDINATE to the COORDINATE. -- @param #COORDINATE self -- @param #COORDINATE FromCoordinate The coordinate to measure the distance and the bearing from. - -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param Core.Settings#SETTINGS Settings (Optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @return #string The BR text. function COORDINATE:ToStringBR( FromCoordinate, Settings ) local DirectionVec3 = FromCoordinate:GetDirectionVec3( self ) @@ -2539,7 +2539,7 @@ do -- COORDINATE --- Return a BRAA string from a COORDINATE to the COORDINATE. -- @param #COORDINATE self -- @param #COORDINATE FromCoordinate The coordinate to measure the distance and the bearing from. - -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param Core.Settings#SETTINGS Settings (Optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @return #string The BR text. function COORDINATE:ToStringBRA( FromCoordinate, Settings, Language ) local DirectionVec3 = FromCoordinate:GetDirectionVec3( self ) @@ -2552,7 +2552,7 @@ do -- COORDINATE --- Return a BULLS string out of the BULLS of the coalition to the COORDINATE. -- @param #COORDINATE self -- @param DCS#coalition.side Coalition The coalition. - -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param Core.Settings#SETTINGS Settings (Optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @return #string The BR text. function COORDINATE:ToStringBULLS( Coalition, Settings ) local BullsCoordinate = COORDINATE:NewFromVec3( coalition.getMainRefPoint( Coalition ) ) @@ -2600,7 +2600,7 @@ do -- COORDINATE --- Provides a Lat Lon string in Degree Minute Second format. -- @param #COORDINATE self - -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param Core.Settings#SETTINGS Settings (Optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @return #string The LL DMS Text function COORDINATE:ToStringLLDMS( Settings ) @@ -2611,7 +2611,7 @@ do -- COORDINATE --- Provides a Lat Lon string in Degree Decimal Minute format. -- @param #COORDINATE self - -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param Core.Settings#SETTINGS Settings (Optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @return #string The LL DDM Text function COORDINATE:ToStringLLDDM( Settings ) @@ -2622,7 +2622,7 @@ do -- COORDINATE --- Provides a MGRS string -- @param #COORDINATE self - -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param Core.Settings#SETTINGS Settings (Optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @return #string The MGRS Text function COORDINATE:ToStringMGRS( Settings ) -- R2.1 Fixes issue #424. @@ -2639,7 +2639,7 @@ do -- COORDINATE -- @param #COORDINATE ReferenceCoord The refrence coordinate. -- @param #string ReferenceName The refrence name. -- @param Wrapper.Controllable#CONTROLLABLE Controllable - -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param Core.Settings#SETTINGS Settings (Optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @return #string The coordinate Text in the configured coordinate system. function COORDINATE:ToStringFromRP( ReferenceCoord, ReferenceName, Controllable, Settings ) @@ -2668,7 +2668,7 @@ do -- COORDINATE --- Provides a coordinate string of the point, based on the A2G coordinate format system. -- @param #COORDINATE self -- @param Wrapper.Controllable#CONTROLLABLE Controllable - -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param Core.Settings#SETTINGS Settings (Optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @return #string The coordinate Text in the configured coordinate system. function COORDINATE:ToStringA2G( Controllable, Settings ) @@ -2702,7 +2702,7 @@ do -- COORDINATE --- Provides a coordinate string of the point, based on the A2A coordinate format system. -- @param #COORDINATE self -- @param Wrapper.Controllable#CONTROLLABLE Controllable - -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param Core.Settings#SETTINGS Settings (Optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @return #string The coordinate Text in the configured coordinate system. function COORDINATE:ToStringA2A( Controllable, Settings, Language ) -- R2.2 @@ -2741,7 +2741,7 @@ do -- COORDINATE -- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default. -- @param #COORDINATE self -- @param Wrapper.Controllable#CONTROLLABLE Controllable The controllable to retrieve the settings from, otherwise the default settings will be chosen. - -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param Core.Settings#SETTINGS Settings (Optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @param Tasking.Task#TASK Task The task for which coordinates need to be calculated. -- @return #string The coordinate Text in the configured coordinate system. function COORDINATE:ToString( Controllable, Settings, Task ) @@ -2793,7 +2793,7 @@ do -- COORDINATE -- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default. -- @param #COORDINATE self -- @param Wrapper.Controllable#CONTROLLABLE Controllable - -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param Core.Settings#SETTINGS Settings (Optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @return #string The pressure text in the configured measurement system. function COORDINATE:ToStringPressure( Controllable, Settings ) -- R2.3 @@ -2809,7 +2809,7 @@ do -- COORDINATE -- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default. -- @param #COORDINATE self -- @param Wrapper.Controllable#CONTROLLABLE Controllable - -- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. + -- @param Core.Settings#SETTINGS Settings (Optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object. -- @return #string The wind text in the configured measurement system. function COORDINATE:ToStringWind( Controllable, Settings ) @@ -2940,7 +2940,7 @@ do -- POINT_VEC3 --- Create a new POINT_VEC3 object from Vec2 coordinates. -- @param #POINT_VEC3 self -- @param DCS#Vec2 Vec2 The Vec2 point. - -- @param DCS#Distance LandHeightAdd (optional) Add a landheight. + -- @param DCS#Distance LandHeightAdd (Optional) Add a landheight. -- @return Core.Point#POINT_VEC3 self function POINT_VEC3:NewFromVec2( Vec2, LandHeightAdd ) @@ -3088,7 +3088,7 @@ do -- POINT_VEC2 -- @param #POINT_VEC2 self -- @param DCS#Distance x The x coordinate of the Vec3 point, pointing to the North. -- @param DCS#Distance y The y coordinate of the Vec3 point, pointing to the Right. - -- @param DCS#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height. + -- @param DCS#Distance LandHeightAdd (Optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height. -- @return Core.Point#POINT_VEC2 function POINT_VEC2:New( x, y, LandHeightAdd ) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 679ba9820..35f3c3b35 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -44,7 +44,6 @@ -- @module Core.Set -- @image Core_Sets.JPG - do -- SET_BASE --- @type SET_BASE @@ -55,7 +54,6 @@ do -- SET_BASE -- @field Core.Scheduler#SCHEDULER CallScheduler -- @extends Core.Base#BASE - --- The @{Core.Set#SET_BASE} class defines the core functions that define a collection of objects. -- A SET provides iterators to iterate the SET, but will **temporarily** yield the ForEach iterator loop at defined **"intervals"** to the mail simulator loop. -- In this way, large loops can be done while not blocking the simulator main processing loop. @@ -79,12 +77,11 @@ do -- SET_BASE List = {}, Index = {}, Database = nil, - CallScheduler=nil, - TimeInterval=nil, - YieldInterval=nil, + CallScheduler = nil, + TimeInterval = nil, + YieldInterval = nil, } - --- Creates a new SET_BASE object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names. -- @param #SET_BASE self -- @return #SET_BASE @@ -109,8 +106,7 @@ do -- SET_BASE -- @param #string ObjectName The name of the object. -- @param Object The object. - - self:AddTransition( "*", "Added", "*" ) + self:AddTransition( "*", "Added", "*" ) --- Removed Handler OnAfter for SET_BASE -- @function [parent=#SET_BASE] OnAfterRemoved @@ -121,7 +117,7 @@ do -- SET_BASE -- @param #string ObjectName The name of the object. -- @param Object The object. - self:AddTransition( "*", "Removed", "*" ) + self:AddTransition( "*", "Removed", "*" ) self.YieldInterval = 10 self.TimeInterval = 0.001 @@ -148,8 +144,6 @@ do -- SET_BASE return self end - - --- Finds an @{Core.Base#BASE} object based on the object Name. -- @param #SET_BASE self -- @param #string ObjectName @@ -160,7 +154,6 @@ do -- SET_BASE return ObjectFound end - --- Gets the Set. -- @param #SET_BASE self -- @return #SET_BASE self @@ -173,7 +166,7 @@ do -- SET_BASE --- Gets a list of the Names of the Objects in the Set. -- @param #SET_BASE self -- @return #SET_BASE self - function SET_BASE:GetSetNames() -- R2.3 + function SET_BASE:GetSetNames() -- R2.3 self:F2() local Names = {} @@ -185,11 +178,10 @@ do -- SET_BASE return Names end - --- Gets a list of the Objects in the Set. -- @param #SET_BASE self -- @return #SET_BASE self - function SET_BASE:GetSetObjects() -- R2.3 + function SET_BASE:GetSetObjects() -- R2.3 self:F2() local Objects = {} @@ -201,17 +193,18 @@ do -- SET_BASE return Objects end - --- Removes a @{Core.Base#BASE} object from the @{Core.Set#SET_BASE} and derived classes, based on the Object Name. -- @param #SET_BASE self -- @param #string ObjectName - -- @param NoTriggerEvent (optional) When `true`, the :Remove() method will not trigger a **Removed** event. + -- @param NoTriggerEvent (Optional) When `true`, the :Remove() method will not trigger a **Removed** event. function SET_BASE:Remove( ObjectName, NoTriggerEvent ) self:F2( { ObjectName = ObjectName } ) - + local TriggerEvent = true - if NoTriggerEvent == false then TriggerEvent = false end - + if NoTriggerEvent == false then + TriggerEvent = false + end + local Object = self.Set[ObjectName] if Object then @@ -229,14 +222,13 @@ do -- SET_BASE end end - --- Adds a @{Core.Base#BASE} object in the @{Core.Set#SET_BASE}, using a given ObjectName as the index. -- @param #SET_BASE self -- @param #string ObjectName The name of the object. -- @param Core.Base#BASE Object The object itself. -- @return Core.Base#BASE The added BASE Object. function SET_BASE:Add( ObjectName, Object ) - + -- Debug info. self:T( { ObjectName = ObjectName, Object = Object } ) @@ -272,43 +264,42 @@ do -- SET_BASE -- @param #SET_BASE self -- @return Core.Base#BASE The added BASE Object. function SET_BASE:SortByName() - - local function sort(a, b) - return a= Limit then - break - end - -- if Count % self.YieldInterval == 0 then - -- coroutine.yield( false ) - -- end + else + IteratorFunction( Object, unpack( arg ) ) + end + Count = Count + 1 + if Count >= Limit then + break + end + -- if Count % self.YieldInterval == 0 then + -- coroutine.yield( false ) + -- end end return true end - -- local co = coroutine.create( CoRoutine ) + -- local co = coroutine.create( CoRoutine ) local co = CoRoutine local function Schedule() - -- local status, res = coroutine.resume( co ) + -- local status, res = coroutine.resume( co ) local status, res = co() self:T3( { status, res } ) @@ -780,50 +759,48 @@ do -- SET_BASE return false end - --self.CallScheduler:Schedule( self, Schedule, {}, self.TimeInterval, self.TimeInterval, 0 ) + -- self.CallScheduler:Schedule( self, Schedule, {}, self.TimeInterval, self.TimeInterval, 0 ) Schedule() return self end - ----- Iterate the SET_BASE and call an iterator function for each **alive** unit, providing the Unit and optional parameters. ---- @param #SET_BASE self ---- @param #function IteratorFunction The function that will be called when there is an alive unit in the SET_BASE. The function needs to accept a UNIT parameter. ---- @return #SET_BASE self - --function SET_BASE:ForEachDCSUnitAlive( IteratorFunction, ... ) + -- function SET_BASE:ForEachDCSUnitAlive( IteratorFunction, ... ) -- self:F3( arg ) -- -- self:ForEach( IteratorFunction, arg, self.DCSUnitsAlive ) -- -- return self - --end + -- end -- ----- Iterate the SET_BASE and call an iterator function for each **alive** player, providing the Unit of the player 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. The function needs to accept a UNIT parameter. ---- @return #SET_BASE self - --function SET_BASE:ForEachPlayer( IteratorFunction, ... ) + -- function SET_BASE:ForEachPlayer( IteratorFunction, ... ) -- self:F3( arg ) -- -- self:ForEach( IteratorFunction, arg, self.PlayersAlive ) -- -- return self - --end + -- end -- -- ----- Iterate the SET_BASE and call an iterator function for each client, providing the Client to the function 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. The function needs to accept a CLIENT parameter. ---- @return #SET_BASE self - --function SET_BASE:ForEachClient( IteratorFunction, ... ) + -- function SET_BASE:ForEachClient( IteratorFunction, ... ) -- self:F3( arg ) -- -- self:ForEach( IteratorFunction, arg, self.Clients ) -- -- return self - --end - + -- end --- Decides whether to include the Object. -- @param #SET_BASE self @@ -839,7 +816,7 @@ do -- SET_BASE -- @param #SET_BASE self -- @param #table Object -- @return #SET_BASE self - function SET_BASE:IsInSet(ObjectName) + function SET_BASE:IsInSet( ObjectName ) self:F3( Object ) return true @@ -861,7 +838,7 @@ do -- SET_BASE --- Flushes the current SET_BASE contents in the log ... (for debugging reasons). -- @param #SET_BASE self - -- @param Core.Base#BASE MasterObject (optional) The master object as a reference. + -- @param Core.Base#BASE MasterObject (Optional) The master object as a reference. -- @return #string A string with the names of the objects. function SET_BASE:Flush( MasterObject ) self:F3() @@ -877,7 +854,6 @@ do -- SET_BASE end - do -- SET_GROUP --- @type SET_GROUP @@ -1010,7 +986,6 @@ do -- SET_GROUP }, } - --- Creates a new SET_GROUP object, building a set of groups belonging to a coalitions, categories, countries, types or with defined prefix names. -- @param #SET_GROUP self -- @return #SET_GROUP @@ -1037,7 +1012,7 @@ do -- SET_GROUP -- Clean the Set before returning with only the alive Groups. for GroupName, GroupObject in pairs( self.Set ) do - local GroupObject=GroupObject --Wrapper.Group#GROUP + local GroupObject = GroupObject -- Wrapper.Group#GROUP if GroupObject then if GroupObject:IsAlive() then AliveSet:Add( GroupName, GroupObject ) @@ -1104,7 +1079,7 @@ do -- SET_GROUP -- @return Core.Set#SET_GROUP self function SET_GROUP:AddGroupsByName( AddGroupNames ) - local AddGroupNamesArray = ( type( AddGroupNames ) == "table" ) and AddGroupNames or { AddGroupNames } + local AddGroupNamesArray = (type( AddGroupNames ) == "table") and AddGroupNames or { AddGroupNames } for AddGroupID, AddGroupName in pairs( AddGroupNamesArray ) do self:Add( AddGroupName, GROUP:FindByName( AddGroupName ) ) @@ -1119,7 +1094,7 @@ do -- SET_GROUP -- @return Core.Set#SET_GROUP self function SET_GROUP:RemoveGroupsByName( RemoveGroupNames ) - local RemoveGroupNamesArray = ( type( RemoveGroupNames ) == "table" ) and RemoveGroupNames or { RemoveGroupNames } + local RemoveGroupNamesArray = (type( RemoveGroupNames ) == "table") and RemoveGroupNames or { RemoveGroupNames } for RemoveGroupID, RemoveGroupName in pairs( RemoveGroupNamesArray ) do self:Remove( RemoveGroupName ) @@ -1128,9 +1103,6 @@ do -- SET_GROUP return self end - - - --- Finds a Group based on the Group Name. -- @param #SET_GROUP self -- @param #string GroupName @@ -1148,7 +1120,7 @@ do -- SET_GROUP function SET_GROUP:FindNearestGroupFromPointVec2( PointVec2 ) self:F2( PointVec2 ) - local NearestGroup = nil --Wrapper.Group#GROUP + local NearestGroup = nil -- Wrapper.Group#GROUP local ClosestDistance = nil for ObjectID, ObjectData in pairs( self.Set ) do @@ -1167,7 +1139,6 @@ do -- SET_GROUP return NearestGroup end - --- Builds a set of groups in zones. -- @param #SET_GROUP self -- @param #table Zones Table of Core.Zone#ZONE Zone objects, or a Core.Set#SET_ZONE @@ -1179,13 +1150,13 @@ do -- SET_GROUP local zones = {} if Zones.ClassName and Zones.ClassName == "SET_ZONE" then zones = Zones.Set - elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName ) then - self:E("***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!") - return self + elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName) then + self:E( "***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!" ) + return self else zones = Zones end - for _,Zone in pairs( zones ) do + for _, Zone in pairs( zones ) do local zonename = Zone:GetName() self.Filter.Zones[zonename] = Zone end @@ -1210,7 +1181,6 @@ do -- SET_GROUP return self end - --- Builds a set of groups out of categories. -- Possible current categories are plane, helicopter, ground, ship. -- @param #SET_GROUP self @@ -1269,8 +1239,6 @@ do -- SET_GROUP return self end - - --- Builds a set of groups of defined countries. -- Possible current countries are those known within DCS world. -- @param #SET_GROUP self @@ -1289,7 +1257,6 @@ do -- SET_GROUP return self end - --- Builds a set of groups that contain the given string in their group name. -- **Attention!** Bad naming convention as this **does not** filter only **prefixes** but all groups that **contain** the string. -- @param #SET_GROUP self @@ -1311,7 +1278,7 @@ do -- SET_GROUP --- Builds a set of groups that are only active. -- Only the groups that are active will be included within the set. -- @param #SET_GROUP self - -- @param #boolean Active (optional) Include only active groups to the set. + -- @param #boolean Active (Optional) Include only active groups to the set. -- Include inactive groups if you provide false. -- @return #SET_GROUP self -- @usage @@ -1329,12 +1296,11 @@ do -- SET_GROUP -- GroupSet = SET_GROUP:New():FilterActive( false ):FilterCoalition( "blue" ):FilterOnce() -- function SET_GROUP:FilterActive( Active ) - Active = Active or not ( Active == false ) + Active = Active or not (Active == false) self.Filter.Active = Active return self end - --- Starts the filtering. -- @param #SET_GROUP self -- @return #SET_GROUP self @@ -1348,8 +1314,6 @@ do -- SET_GROUP self:HandleEvent( EVENTS.RemoveUnit, self._EventOnDeadOrCrash ) end - - return self end @@ -1453,18 +1417,17 @@ do -- SET_GROUP -- @param #SET_GROUP self -- @param #number Delay Delay in seconds. -- @return #SET_GROUP self - function SET_GROUP:Activate(Delay) + function SET_GROUP:Activate( Delay ) local Set = self:GetSet() - for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP - local group=GroupData --Wrapper.Group#GROUP - if group and group:IsAlive()==false then - group:Activate(Delay) + for GroupID, GroupData in pairs( Set ) do -- For each GROUP in SET_GROUP + local group = GroupData -- Wrapper.Group#GROUP + if group and group:IsAlive() == false then + group:Activate( Delay ) end end 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 Core.Zone#ZONE ZoneObject The Zone to be tested for. @@ -1545,11 +1508,11 @@ do -- SET_GROUP -- else -- MESSAGE:New("Some or all SET's GROUP are outside zone !", 10):ToAll() -- end - function SET_GROUP:AllCompletelyInZone(Zone) - self:F2(Zone) + function SET_GROUP:AllCompletelyInZone( Zone ) + self:F2( Zone ) local Set = self:GetSet() - for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP - if not GroupData:IsCompletelyInZone(Zone) then + for GroupID, GroupData in pairs( Set ) do -- For each GROUP in SET_GROUP + if not GroupData:IsCompletelyInZone( Zone ) then return false end end @@ -1578,7 +1541,6 @@ do -- SET_GROUP return self end - --- Iterate the SET_GROUP and return true if at least one of the @{Wrapper.Group#GROUP} is completely inside the @{Core.Zone#ZONE} -- @param #SET_GROUP self -- @param Core.Zone#ZONE ZoneObject The Zone to be tested for. @@ -1593,11 +1555,11 @@ do -- SET_GROUP -- else -- MESSAGE:New("No GROUP is completely in zone !", 10):ToAll() -- end - function SET_GROUP:AnyCompletelyInZone(Zone) - self:F2(Zone) + function SET_GROUP:AnyCompletelyInZone( Zone ) + self:F2( Zone ) local Set = self:GetSet() - for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP - if GroupData:IsCompletelyInZone(Zone) then + for GroupID, GroupData in pairs( Set ) do -- For each GROUP in SET_GROUP + if GroupData:IsCompletelyInZone( Zone ) then return true end end @@ -1618,11 +1580,11 @@ do -- SET_GROUP -- else -- MESSAGE:New("No UNIT of any GROUP is in zone !", 10):ToAll() -- end - function SET_GROUP:AnyInZone(Zone) - self:F2(Zone) + function SET_GROUP:AnyInZone( Zone ) + self:F2( Zone ) local Set = self:GetSet() - for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP - if GroupData:IsPartlyInZone(Zone) or GroupData:IsCompletelyInZone(Zone) then + for GroupID, GroupData in pairs( Set ) do -- For each GROUP in SET_GROUP + if GroupData:IsPartlyInZone( Zone ) or GroupData:IsCompletelyInZone( Zone ) then return true end end @@ -1644,14 +1606,14 @@ do -- SET_GROUP -- else -- MESSAGE:New("No GROUP are in zone, or one (or more) GROUP is completely in it !", 10):ToAll() -- end - function SET_GROUP:AnyPartlyInZone(Zone) - self:F2(Zone) + function SET_GROUP:AnyPartlyInZone( Zone ) + self:F2( Zone ) local IsPartlyInZone = false local Set = self:GetSet() - for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP - if GroupData:IsCompletelyInZone(Zone) then + for GroupID, GroupData in pairs( Set ) do -- For each GROUP in SET_GROUP + if GroupData:IsCompletelyInZone( Zone ) then return false - elseif GroupData:IsPartlyInZone(Zone) then + elseif GroupData:IsPartlyInZone( Zone ) then IsPartlyInZone = true -- at least one GROUP is partly in zone end end @@ -1679,11 +1641,11 @@ do -- SET_GROUP -- else -- MESSAGE:New("No UNIT of any GROUP is in zone !", 10):ToAll() -- end - function SET_GROUP:NoneInZone(Zone) - self:F2(Zone) + function SET_GROUP:NoneInZone( Zone ) + self:F2( Zone ) local Set = self:GetSet() - for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP - if not GroupData:IsNotInZone(Zone) then -- If the GROUP is in Zone in any way + for GroupID, GroupData in pairs( Set ) do -- For each GROUP in SET_GROUP + if not GroupData:IsNotInZone( Zone ) then -- If the GROUP is in Zone in any way return false end end @@ -1702,12 +1664,12 @@ do -- SET_GROUP -- MySetGroup:AddGroupsByName({"Group1", "Group2"}) -- -- MESSAGE:New("There are " .. MySetGroup:CountInZone(MyZone) .. " GROUPs in the Zone !", 10):ToAll() - function SET_GROUP:CountInZone(Zone) - self:F2(Zone) + function SET_GROUP:CountInZone( Zone ) + self:F2( Zone ) local Count = 0 local Set = self:GetSet() - for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP - if GroupData:IsCompletelyInZone(Zone) then + for GroupID, GroupData in pairs( Set ) do -- For each GROUP in SET_GROUP + if GroupData:IsCompletelyInZone( Zone ) then Count = Count + 1 end end @@ -1724,12 +1686,12 @@ do -- SET_GROUP -- MySetGroup:AddGroupsByName({"Group1", "Group2"}) -- -- MESSAGE:New("There are " .. MySetGroup:CountUnitInZone(MyZone) .. " UNITs in the Zone !", 10):ToAll() - function SET_GROUP:CountUnitInZone(Zone) - self:F2(Zone) + function SET_GROUP:CountUnitInZone( Zone ) + self:F2( Zone ) local Count = 0 local Set = self:GetSet() - for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP - Count = Count + GroupData:CountInZone(Zone) + for GroupID, GroupData in pairs( Set ) do -- For each GROUP in SET_GROUP + Count = Count + GroupData:CountInZone( Zone ) end return Count end @@ -1744,50 +1706,49 @@ do -- SET_GROUP local Set = self:GetSet() - for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP + for GroupID, GroupData in pairs( Set ) do -- For each GROUP in SET_GROUP if GroupData and GroupData:IsAlive() then CountG = CountG + 1 - --Count Units. - for _,_unit in pairs(GroupData:GetUnits()) do - local unit=_unit --Wrapper.Unit#UNIT + -- Count Units. + for _, _unit in pairs( GroupData:GetUnits() ) do + local unit = _unit -- Wrapper.Unit#UNIT if unit and unit:IsAlive() then - CountU=CountU+1 + CountU = CountU + 1 end end end end - return CountG,CountU + return CountG, CountU end ----- Iterate the SET_GROUP and call an iterator function for each **alive** player, providing the Group of the player and optional parameters. ---- @param #SET_GROUP self ---- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_GROUP. The function needs to accept a GROUP parameter. ---- @return #SET_GROUP self - --function SET_GROUP:ForEachPlayer( IteratorFunction, ... ) + -- function SET_GROUP:ForEachPlayer( IteratorFunction, ... ) -- self:F2( arg ) -- -- self:ForEach( IteratorFunction, arg, self.PlayersAlive ) -- -- return self - --end + -- end -- -- ----- Iterate the SET_GROUP and call an iterator function for each client, providing the Client to the function and optional parameters. ---- @param #SET_GROUP self ---- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_GROUP. The function needs to accept a CLIENT parameter. ---- @return #SET_GROUP self - --function SET_GROUP:ForEachClient( IteratorFunction, ... ) + -- function SET_GROUP:ForEachClient( IteratorFunction, ... ) -- self:F2( arg ) -- -- self:ForEach( IteratorFunction, arg, self.Clients ) -- -- return self - --end - + -- end --- -- @param #SET_GROUP self @@ -1800,7 +1761,7 @@ do -- SET_GROUP if self.Filter.Active ~= nil then local MGroupActive = false self:F( { Active = self.Filter.Active } ) - if self.Filter.Active == false or ( self.Filter.Active == true and MGroup:IsActive() == true ) then + if self.Filter.Active == false or (self.Filter.Active == true and MGroup:IsActive() == true) then MGroupActive = true end MGroupInclude = MGroupInclude and MGroupActive @@ -1843,29 +1804,28 @@ do -- SET_GROUP local MGroupPrefix = false for GroupPrefixId, GroupPrefix in pairs( self.Filter.GroupPrefixes ) do self:T3( { "Prefix:", string.find( MGroup:GetName(), GroupPrefix, 1 ), GroupPrefix } ) - if string.find( MGroup:GetName(), GroupPrefix:gsub ("-", "%%-"), 1 ) then + if string.find( MGroup:GetName(), GroupPrefix:gsub( "-", "%%-" ), 1 ) then MGroupPrefix = true end end MGroupInclude = MGroupInclude and MGroupPrefix end - + if self.Filter.Zones then local MGroupZone = false for ZoneName, Zone in pairs( self.Filter.Zones ) do self:T3( "Zone:", ZoneName ) - if MGroup:IsInZone(Zone) then + if MGroup:IsInZone( Zone ) then MGroupZone = true end end MGroupInclude = MGroupInclude and MGroupZone end - + self:T2( MGroupInclude ) return MGroupInclude end - --- Iterate the SET_GROUP and set for each unit the default cargo bay weight limit. -- Because within a group, the type of carriers can differ, each cargo bay weight limit is set on @{Wrapper.Unit} level. -- @param #SET_GROUP self @@ -1877,7 +1837,7 @@ do -- SET_GROUP local Set = self:GetSet() for GroupID, GroupData in pairs( Set ) do -- For each GROUP in SET_GROUP for UnitName, UnitData in pairs( GroupData:GetUnits() ) do - --local UnitData = UnitData -- Wrapper.Unit#UNIT + -- local UnitData = UnitData -- Wrapper.Unit#UNIT UnitData:SetCargoBayWeightLimit() end end @@ -1885,7 +1845,6 @@ do -- SET_GROUP end - do -- SET_UNIT --- @type SET_UNIT @@ -2059,14 +2018,13 @@ do -- SET_UNIT return self end - --- Add UNIT(s) to SET_UNIT. -- @param #SET_UNIT self -- @param #string AddUnitNames A single name or an array of UNIT names. -- @return #SET_UNIT self function SET_UNIT:AddUnitsByName( AddUnitNames ) - local AddUnitNamesArray = ( type( AddUnitNames ) == "table" ) and AddUnitNames or { AddUnitNames } + local AddUnitNamesArray = (type( AddUnitNames ) == "table") and AddUnitNames or { AddUnitNames } self:T( AddUnitNamesArray ) for AddUnitID, AddUnitName in pairs( AddUnitNamesArray ) do @@ -2082,7 +2040,7 @@ do -- SET_UNIT -- @return Core.Set#SET_UNIT self function SET_UNIT:RemoveUnitsByName( RemoveUnitNames ) - local RemoveUnitNamesArray = ( type( RemoveUnitNames ) == "table" ) and RemoveUnitNames or { RemoveUnitNames } + local RemoveUnitNamesArray = (type( RemoveUnitNames ) == "table") and RemoveUnitNames or { RemoveUnitNames } for RemoveUnitID, RemoveUnitName in pairs( RemoveUnitNamesArray ) do self:Remove( RemoveUnitName ) @@ -2091,7 +2049,6 @@ do -- SET_UNIT return self end - --- Finds a Unit based on the Unit Name. -- @param #SET_UNIT self -- @param #string UnitName @@ -2102,8 +2059,6 @@ do -- SET_UNIT return UnitFound end - - --- Builds a set of units of coalitions. -- Possible current coalitions are red, blue and neutral. -- @param #SET_UNIT self @@ -2121,7 +2076,6 @@ do -- SET_UNIT return self end - --- Builds a set of units out of categories. -- Possible current categories are plane, helicopter, ground, ship. -- @param #SET_UNIT self @@ -2140,7 +2094,6 @@ do -- SET_UNIT return self end - --- Builds a set of units of defined unit types. -- Possible current types are those types known within DCS world. -- @param #SET_UNIT self @@ -2159,7 +2112,6 @@ do -- SET_UNIT return self end - --- Builds a set of units of defined countries. -- Possible current countries are those known within DCS world. -- @param #SET_UNIT self @@ -2178,7 +2130,6 @@ do -- SET_UNIT return self end - --- Builds a set of UNITs that contain a given string in their unit name. -- **Attention!** Bad naming convention as this **does not** filter only **prefixes** but all units that **contain** the string. -- @param #SET_UNIT self @@ -2196,7 +2147,7 @@ do -- SET_UNIT end return self end - + --- Builds a set of units in zones. -- @param #SET_UNIT self -- @param #table Zones Table of Core.Zone#ZONE Zone objects, or a Core.Set#SET_ZONE @@ -2208,23 +2159,23 @@ do -- SET_UNIT local zones = {} if Zones.ClassName and Zones.ClassName == "SET_ZONE" then zones = Zones.Set - elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName ) then - self:E("***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!") - return self + elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName) then + self:E( "***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!" ) + return self else zones = Zones end - for _,Zone in pairs( zones ) do + for _, Zone in pairs( zones ) do local zonename = Zone:GetName() self.Filter.Zones[zonename] = Zone end return self end - + --- Builds a set of units that are only active. -- Only the units that are active will be included within the set. -- @param #SET_UNIT self - -- @param #boolean Active (optional) Include only active units to the set. + -- @param #boolean Active (Optional) Include only active units to the set. -- Include inactive units if you provide false. -- @return #SET_UNIT self -- @usage @@ -2242,7 +2193,7 @@ do -- SET_UNIT -- UnitSet = SET_UNIT:New():FilterActive( false ):FilterCoalition( "blue" ):FilterOnce() -- function SET_UNIT:FilterActive( Active ) - Active = Active or not ( Active == false ) + Active = Active or not (Active == false) self.Filter.Active = Active return self end @@ -2281,7 +2232,7 @@ do -- SET_UNIT local Set = self:GetSet() local CountU = 0 - for UnitID, UnitData in pairs(Set) do -- For each GROUP in SET_GROUP + for UnitID, UnitData in pairs( Set ) do -- For each GROUP in SET_GROUP if UnitData and UnitData:IsAlive() then CountU = CountU + 1 end @@ -2307,8 +2258,6 @@ do -- SET_UNIT return self end - - --- Handles the Database to check on an event (birth) that the Object was added in the Database. -- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event! -- @param #SET_UNIT self @@ -2337,11 +2286,9 @@ do -- SET_UNIT function SET_UNIT:FindInDatabase( Event ) self:F2( { Event.IniDCSUnitName, self.Set[Event.IniDCSUnitName], Event } ) - return Event.IniDCSUnitName, self.Set[Event.IniDCSUnitName] end - do -- Is Zone methods --- Check if minimal one element of the SET_UNIT is in the Zone. @@ -2354,7 +2301,7 @@ do -- SET_UNIT local function EvaluateZone( ZoneUnit ) - local ZoneUnitName = ZoneUnit:GetName() + local ZoneUnitName = ZoneUnit:GetName() self:F( { ZoneUnitName = ZoneUnitName } ) if self:FindUnit( ZoneUnitName ) then IsPartiallyInZone = true @@ -2370,7 +2317,6 @@ do -- SET_UNIT return IsPartiallyInZone end - --- Check if no element of the SET_UNIT is in the Zone. -- @param #SET_UNIT self -- @param Core.Zone#ZONE ZoneObject The Zone to be tested for. @@ -2381,7 +2327,7 @@ do -- SET_UNIT local function EvaluateZone( ZoneUnit ) - local ZoneUnitName = ZoneUnit:GetName() + local ZoneUnitName = ZoneUnit:GetName() if self:FindUnit( ZoneUnitName ) then IsNotInZone = false return false @@ -2397,7 +2343,6 @@ do -- SET_UNIT end - --- Iterate the SET_UNIT and call an iterator function for each **alive** UNIT, providing the UNIT and optional parameters. -- @param #SET_UNIT self -- @param #function IteratorFunction The function that will be called when there is an alive UNIT in the SET_UNIT. The function needs to accept a UNIT parameter. @@ -2410,16 +2355,12 @@ do -- SET_UNIT return self end - --- Get the SET of the SET_UNIT **sorted per Threat Level**. -- -- @param #SET_UNIT self -- @param #number FromThreatLevel The TreatLevel to start the evaluation **From** (this must be a value between 0 and 10). -- @param #number ToThreatLevel The TreatLevel to stop the evaluation **To** (this must be a value between 0 and 10). -- @return #SET_UNIT self - -- @usage - -- - -- function SET_UNIT:GetSetPerThreatLevel( FromThreatLevel, ToThreatLevel ) self:F2( arg ) @@ -2436,12 +2377,10 @@ do -- SET_UNIT self:F( { ThreatLevel = ThreatLevel, ThreatLevelSet = ThreatLevelSet[ThreatLevel].Set } ) end - local OrderedPerThreatLevelSet = {} local ThreatLevelIncrement = FromThreatLevel <= ToThreatLevel and 1 or -1 - for ThreatLevel = FromThreatLevel, ToThreatLevel, ThreatLevelIncrement do self:F( { ThreatLevel = ThreatLevel } ) local ThreatLevelItem = ThreatLevelSet[ThreatLevel] @@ -2457,7 +2396,6 @@ do -- SET_UNIT end - --- Iterate the SET_UNIT **sorted *per Threat Level** and call an iterator function for each **alive** UNIT, providing the UNIT and optional parameters. -- -- @param #SET_UNIT self @@ -2474,7 +2412,7 @@ do -- SET_UNIT -- end -- ) -- - function SET_UNIT:ForEachUnitPerThreatLevel( FromThreatLevel, ToThreatLevel, IteratorFunction, ... ) --R2.1 Threat Level implementation + function SET_UNIT:ForEachUnitPerThreatLevel( FromThreatLevel, ToThreatLevel, IteratorFunction, ... ) -- R2.1 Threat Level implementation self:F2( arg ) local ThreatLevelSet = {} @@ -2504,8 +2442,6 @@ do -- SET_UNIT return self end - - --- Iterate the SET_UNIT and call an iterator function for each **alive** UNIT presence completely in a @{Zone}, providing the UNIT and optional parameters to the called function. -- @param #SET_UNIT self -- @param Core.Zone#ZONE ZoneObject The Zone to be tested for. @@ -2573,13 +2509,12 @@ do -- SET_UNIT end for UnitTypeID, UnitType in pairs( UnitTypes ) do - MT[#MT+1] = UnitType .. " of " .. UnitTypeID + MT[#MT + 1] = UnitType .. " of " .. UnitTypeID end return UnitTypes end - --- Returns a comma separated string of the unit types with a count in the @{Set}. -- @param #SET_UNIT self -- @return #string The unit types string @@ -2590,7 +2525,7 @@ do -- SET_UNIT local UnitTypes = self:GetUnitTypes() for UnitTypeID, UnitType in pairs( UnitTypes ) do - MT[#MT+1] = UnitType .. " of " .. UnitTypeID + MT[#MT + 1] = UnitType .. " of " .. UnitTypeID end return table.concat( MT, ", " ) @@ -2663,27 +2598,27 @@ do -- SET_UNIT local Unit = UnitData -- Wrapper.Unit#UNIT local Coordinate = Unit:GetCoordinate() - x1 = ( Coordinate.x < x1 ) and Coordinate.x or x1 - x2 = ( Coordinate.x > x2 ) and Coordinate.x or x2 - y1 = ( Coordinate.y < y1 ) and Coordinate.y or y1 - y2 = ( Coordinate.y > y2 ) and Coordinate.y or y2 - z1 = ( Coordinate.y < z1 ) and Coordinate.z or z1 - z2 = ( Coordinate.y > z2 ) and Coordinate.z or z2 + x1 = (Coordinate.x < x1) and Coordinate.x or x1 + x2 = (Coordinate.x > x2) and Coordinate.x or x2 + y1 = (Coordinate.y < y1) and Coordinate.y or y1 + y2 = (Coordinate.y > y2) and Coordinate.y or y2 + z1 = (Coordinate.y < z1) and Coordinate.z or z1 + z2 = (Coordinate.y > z2) and Coordinate.z or z2 local Velocity = Coordinate:GetVelocity() - if Velocity ~= 0 then - MaxVelocity = ( MaxVelocity < Velocity ) and Velocity or MaxVelocity + if Velocity ~= 0 then + MaxVelocity = (MaxVelocity < Velocity) and Velocity or MaxVelocity local Heading = Coordinate:GetHeading() - AvgHeading = AvgHeading and ( AvgHeading + Heading ) or Heading + AvgHeading = AvgHeading and (AvgHeading + Heading) or Heading MovingCount = MovingCount + 1 end end - AvgHeading = AvgHeading and ( AvgHeading / MovingCount ) + AvgHeading = AvgHeading and (AvgHeading / MovingCount) - Coordinate.x = ( x2 - x1 ) / 2 + x1 - Coordinate.y = ( y2 - y1 ) / 2 + y1 - Coordinate.z = ( z2 - z1 ) / 2 + z1 + Coordinate.x = (x2 - x1) / 2 + x1 + Coordinate.y = (y2 - y1) / 2 + y1 + Coordinate.z = (z2 - z1) / 2 + z1 Coordinate:SetHeading( AvgHeading ) Coordinate:SetVelocity( MaxVelocity ) @@ -2707,8 +2642,8 @@ do -- SET_UNIT local Coordinate = Unit:GetCoordinate() local Velocity = Coordinate:GetVelocity() - if Velocity ~= 0 then - MaxVelocity = ( MaxVelocity < Velocity ) and Velocity or MaxVelocity + if Velocity ~= 0 then + MaxVelocity = (MaxVelocity < Velocity) and Velocity or MaxVelocity end end @@ -2731,12 +2666,12 @@ do -- SET_UNIT local Coordinate = Unit:GetCoordinate() local Velocity = Coordinate:GetVelocity() - if Velocity ~= 0 then + if Velocity ~= 0 then local Heading = Coordinate:GetHeading() if HeadingSet == nil then HeadingSet = Heading else - local HeadingDiff = ( HeadingSet - Heading + 180 + 360 ) % 360 - 180 + local HeadingDiff = (HeadingSet - Heading + 180 + 360) % 360 - 180 HeadingDiff = math.abs( HeadingDiff ) if HeadingDiff > 5 then HeadingSet = nil @@ -2750,8 +2685,6 @@ do -- SET_UNIT end - - --- Returns if the @{Set} has targets having a radar (of a given type). -- @param #SET_UNIT self -- @param DCS#Unit.RadarType RadarType @@ -2760,7 +2693,7 @@ do -- SET_UNIT self:F2( RadarType ) local RadarCount = 0 - for UnitID, UnitData in pairs( self:GetSet()) do + for UnitID, UnitData in pairs( self:GetSet() ) do local UnitSensorTest = UnitData -- Wrapper.Unit#UNIT local HasSensors if RadarType then @@ -2768,7 +2701,7 @@ do -- SET_UNIT else HasSensors = UnitSensorTest:HasSensors( Unit.SensorType.RADAR ) end - self:T3(HasSensors) + self:T3( HasSensors ) if HasSensors then RadarCount = RadarCount + 1 end @@ -2784,14 +2717,14 @@ do -- SET_UNIT self:F2() local SEADCount = 0 - for UnitID, UnitData in pairs( self:GetSet()) do + for UnitID, UnitData in pairs( self:GetSet() ) do local UnitSEAD = UnitData -- Wrapper.Unit#UNIT if UnitSEAD:IsAlive() then local UnitSEADAttributes = UnitSEAD:GetDesc().attributes local HasSEAD = UnitSEAD:HasSEAD() - self:T3(HasSEAD) + self:T3( HasSEAD ) if HasSEAD then SEADCount = SEADCount + 1 end @@ -2808,7 +2741,7 @@ do -- SET_UNIT self:F2() local GroundUnitCount = 0 - for UnitID, UnitData in pairs( self:GetSet()) do + for UnitID, UnitData in pairs( self:GetSet() ) do local UnitTest = UnitData -- Wrapper.Unit#UNIT if UnitTest:IsGround() then GroundUnitCount = GroundUnitCount + 1 @@ -2842,7 +2775,7 @@ do -- SET_UNIT self:F2() local FriendlyUnitCount = 0 - for UnitID, UnitData in pairs( self:GetSet()) do + for UnitID, UnitData in pairs( self:GetSet() ) do local UnitTest = UnitData -- Wrapper.Unit#UNIT if UnitTest:IsFriendly( FriendlyCoalition ) then FriendlyUnitCount = FriendlyUnitCount + 1 @@ -2852,33 +2785,30 @@ do -- SET_UNIT return FriendlyUnitCount end - - ----- Iterate the SET_UNIT and call an iterator function for each **alive** player, providing the Unit of the player and optional parameters. ---- @param #SET_UNIT self ---- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_UNIT. The function needs to accept a UNIT parameter. ---- @return #SET_UNIT self - --function SET_UNIT:ForEachPlayer( IteratorFunction, ... ) + -- function SET_UNIT:ForEachPlayer( IteratorFunction, ... ) -- self:F2( arg ) -- -- self:ForEach( IteratorFunction, arg, self.PlayersAlive ) -- -- return self - --end + -- end -- -- ----- Iterate the SET_UNIT and call an iterator function for each client, providing the Client to the function and optional parameters. ---- @param #SET_UNIT self ---- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_UNIT. The function needs to accept a CLIENT parameter. ---- @return #SET_UNIT self - --function SET_UNIT:ForEachClient( IteratorFunction, ... ) + -- function SET_UNIT:ForEachClient( IteratorFunction, ... ) -- self:F2( arg ) -- -- self:ForEach( IteratorFunction, arg, self.Clients ) -- -- return self - --end - + -- end --- -- @param #SET_UNIT self @@ -2895,7 +2825,7 @@ do -- SET_UNIT if self.Filter.Active ~= nil then local MUnitActive = false - if self.Filter.Active == false or ( self.Filter.Active == true and MUnit:IsActive() == true ) then + if self.Filter.Active == false or (self.Filter.Active == true and MUnit:IsActive() == true) then MUnitActive = true end MUnitInclude = MUnitInclude and MUnitActive @@ -2979,26 +2909,25 @@ do -- SET_UNIT MUnitInclude = MUnitInclude and MUnitSEAD end end - + if self.Filter.Zones then local MGroupZone = false for ZoneName, Zone in pairs( self.Filter.Zones ) do self:T3( "Zone:", ZoneName ) - if MUnit:IsInZone(Zone) then + if MUnit:IsInZone( Zone ) then MGroupZone = true end end - MUnitInclude = MUnitInclude and MGroupZone + MUnitInclude = MUnitInclude and MGroupZone end - + self:T2( MUnitInclude ) return MUnitInclude end - --- Retrieve the type names of the @{Wrapper.Unit}s in the SET, delimited by an optional delimiter. -- @param #SET_UNIT self - -- @param #string Delimiter (optional) The delimiter, which is default a comma. + -- @param #string Delimiter (Optional) The delimiter, which is default a comma. -- @return #string The types of the @{Wrapper.Unit}s delimited. function SET_UNIT:GetTypeNames( Delimiter ) @@ -3029,16 +2958,13 @@ do -- SET_UNIT function SET_UNIT:SetCargoBayWeightLimit() local Set = self:GetSet() for UnitID, UnitData in pairs( Set ) do -- For each UNIT in SET_UNIT - --local UnitData = UnitData -- Wrapper.Unit#UNIT + -- local UnitData = UnitData -- Wrapper.Unit#UNIT UnitData:SetCargoBayWeightLimit() end end - - end - do -- SET_STATIC --- @type SET_STATIC @@ -3157,14 +3083,13 @@ do -- SET_STATIC return self end - --- Add STATIC(s) to SET_STATIC. -- @param #SET_STATIC self -- @param #string AddStaticNames A single name or an array of STATIC names. -- @return #SET_STATIC self function SET_STATIC:AddStaticsByName( AddStaticNames ) - local AddStaticNamesArray = ( type( AddStaticNames ) == "table" ) and AddStaticNames or { AddStaticNames } + local AddStaticNamesArray = (type( AddStaticNames ) == "table") and AddStaticNames or { AddStaticNames } self:T( AddStaticNamesArray ) for AddStaticID, AddStaticName in pairs( AddStaticNamesArray ) do @@ -3180,7 +3105,7 @@ do -- SET_STATIC -- @return self function SET_STATIC:RemoveStaticsByName( RemoveStaticNames ) - local RemoveStaticNamesArray = ( type( RemoveStaticNames ) == "table" ) and RemoveStaticNames or { RemoveStaticNames } + local RemoveStaticNamesArray = (type( RemoveStaticNames ) == "table") and RemoveStaticNames or { RemoveStaticNames } for RemoveStaticID, RemoveStaticName in pairs( RemoveStaticNamesArray ) do self:Remove( RemoveStaticName ) @@ -3189,7 +3114,6 @@ do -- SET_STATIC return self end - --- Finds a Static based on the Static Name. -- @param #SET_STATIC self -- @param #string StaticName @@ -3200,8 +3124,6 @@ do -- SET_STATIC return StaticFound end - - --- Builds a set of units of coalitions. -- Possible current coalitions are red, blue and neutral. -- @param #SET_STATIC self @@ -3219,9 +3141,8 @@ do -- SET_STATIC end return self end - - - --- Builds a set of statics in zones. + + --- Builds a set of statics in zones. -- @param #SET_STATIC self -- @param #table Zones Table of Core.Zone#ZONE Zone objects, or a Core.Set#SET_ZONE -- @return #SET_STATIC self @@ -3232,13 +3153,13 @@ do -- SET_STATIC local zones = {} if Zones.ClassName and Zones.ClassName == "SET_ZONE" then zones = Zones.Set - elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName ) then - self:E("***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!") - return self + elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName) then + self:E( "***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!" ) + return self else zones = Zones end - for _,Zone in pairs( zones ) do + for _, Zone in pairs( zones ) do local zonename = Zone:GetName() self.Filter.Zones[zonename] = Zone end @@ -3263,7 +3184,6 @@ do -- SET_STATIC return self end - --- Builds a set of units of defined unit types. -- Possible current types are those types known within DCS world. -- @param #SET_STATIC self @@ -3282,7 +3202,6 @@ do -- SET_STATIC return self end - --- Builds a set of units of defined countries. -- Possible current countries are those known within DCS world. -- @param #SET_STATIC self @@ -3301,7 +3220,6 @@ do -- SET_STATIC return self end - --- Builds a set of STATICs that contain the given string in their name. -- **Attention!** Bad naming convention as this **does not** filter only **prefixes** but all statics that **contain** the string. -- @param #SET_STATIC self @@ -3320,7 +3238,6 @@ do -- SET_STATIC return self end - --- Starts the filtering. -- @param #SET_STATIC self -- @return #SET_STATIC self @@ -3344,7 +3261,7 @@ do -- SET_STATIC local Set = self:GetSet() local CountU = 0 - for UnitID, UnitData in pairs(Set) do + for UnitID, UnitData in pairs( Set ) do if UnitData and UnitData:IsAlive() then CountU = CountU + 1 end @@ -3382,11 +3299,9 @@ do -- SET_STATIC function SET_STATIC:FindInDatabase( Event ) self:F2( { Event.IniDCSUnitName, self.Set[Event.IniDCSUnitName], Event } ) - return Event.IniDCSUnitName, self.Set[Event.IniDCSUnitName] end - do -- Is Zone methods --- Check if minimal one element of the SET_STATIC is in the Zone. @@ -3399,7 +3314,7 @@ do -- SET_STATIC local function EvaluateZone( ZoneStatic ) - local ZoneStaticName = ZoneStatic:GetName() + local ZoneStaticName = ZoneStatic:GetName() if self:FindStatic( ZoneStaticName ) then IsPartiallyInZone = true return false @@ -3411,7 +3326,6 @@ do -- SET_STATIC return IsPartiallyInZone end - --- Check if no element of the SET_STATIC is in the Zone. -- @param #SET_STATIC self -- @param Core.Zone#ZONE ZoneObject The Zone to be tested for. @@ -3422,7 +3336,7 @@ do -- SET_STATIC local function EvaluateZone( ZoneStatic ) - local ZoneStaticName = ZoneStatic:GetName() + local ZoneStaticName = ZoneStatic:GetName() if self:FindStatic( ZoneStaticName ) then IsNotInZone = false return false @@ -3436,7 +3350,6 @@ do -- SET_STATIC return IsNotInZone end - --- Check if minimal one element of the SET_STATIC is in the Zone. -- @param #SET_STATIC self -- @param #function IteratorFunction The function that will be called when there is an alive STATIC in the SET_STATIC. The function needs to accept a STATIC parameter. @@ -3449,10 +3362,8 @@ do -- SET_STATIC return self end - end - --- Iterate the SET_STATIC and call an iterator function for each **alive** STATIC, providing the STATIC and optional parameters. -- @param #SET_STATIC self -- @param #function IteratorFunction The function that will be called when there is an alive STATIC in the SET_STATIC. The function needs to accept a STATIC parameter. @@ -3465,7 +3376,6 @@ do -- SET_STATIC return self end - --- Iterate the SET_STATIC and call an iterator function for each **alive** STATIC presence completely in a @{Zone}, providing the STATIC and optional parameters to the called function. -- @param #SET_STATIC self -- @param Core.Zone#ZONE ZoneObject The Zone to be tested for. @@ -3533,13 +3443,12 @@ do -- SET_STATIC end for StaticTypeID, StaticType in pairs( StaticTypes ) do - MT[#MT+1] = StaticType .. " of " .. StaticTypeID + MT[#MT + 1] = StaticType .. " of " .. StaticTypeID end return StaticTypes end - --- Returns a comma separated string of the unit types with a count in the @{Set}. -- @param #SET_STATIC self -- @return #string The unit types string @@ -3550,7 +3459,7 @@ do -- SET_STATIC local StaticTypes = self:GetStaticTypes() for StaticTypeID, StaticType in pairs( StaticTypes ) do - MT[#MT+1] = StaticType .. " of " .. StaticTypeID + MT[#MT + 1] = StaticType .. " of " .. StaticTypeID end return table.concat( MT, ", " ) @@ -3578,27 +3487,27 @@ do -- SET_STATIC local Static = StaticData -- Wrapper.Static#STATIC local Coordinate = Static:GetCoordinate() - x1 = ( Coordinate.x < x1 ) and Coordinate.x or x1 - x2 = ( Coordinate.x > x2 ) and Coordinate.x or x2 - y1 = ( Coordinate.y < y1 ) and Coordinate.y or y1 - y2 = ( Coordinate.y > y2 ) and Coordinate.y or y2 - z1 = ( Coordinate.y < z1 ) and Coordinate.z or z1 - z2 = ( Coordinate.y > z2 ) and Coordinate.z or z2 + x1 = (Coordinate.x < x1) and Coordinate.x or x1 + x2 = (Coordinate.x > x2) and Coordinate.x or x2 + y1 = (Coordinate.y < y1) and Coordinate.y or y1 + y2 = (Coordinate.y > y2) and Coordinate.y or y2 + z1 = (Coordinate.y < z1) and Coordinate.z or z1 + z2 = (Coordinate.y > z2) and Coordinate.z or z2 local Velocity = Coordinate:GetVelocity() - if Velocity ~= 0 then - MaxVelocity = ( MaxVelocity < Velocity ) and Velocity or MaxVelocity + if Velocity ~= 0 then + MaxVelocity = (MaxVelocity < Velocity) and Velocity or MaxVelocity local Heading = Coordinate:GetHeading() - AvgHeading = AvgHeading and ( AvgHeading + Heading ) or Heading + AvgHeading = AvgHeading and (AvgHeading + Heading) or Heading MovingCount = MovingCount + 1 end end - AvgHeading = AvgHeading and ( AvgHeading / MovingCount ) + AvgHeading = AvgHeading and (AvgHeading / MovingCount) - Coordinate.x = ( x2 - x1 ) / 2 + x1 - Coordinate.y = ( y2 - y1 ) / 2 + y1 - Coordinate.z = ( z2 - z1 ) / 2 + z1 + Coordinate.x = (x2 - x1) / 2 + x1 + Coordinate.y = (y2 - y1) / 2 + y1 + Coordinate.z = (z2 - z1) / 2 + z1 Coordinate:SetHeading( AvgHeading ) Coordinate:SetVelocity( MaxVelocity ) @@ -3630,12 +3539,12 @@ do -- SET_STATIC local Coordinate = Static:GetCoordinate() local Velocity = Coordinate:GetVelocity() - if Velocity ~= 0 then + if Velocity ~= 0 then local Heading = Coordinate:GetHeading() if HeadingSet == nil then HeadingSet = Heading else - local HeadingDiff = ( HeadingSet - Heading + 180 + 360 ) % 360 - 180 + local HeadingDiff = (HeadingSet - Heading + 180 + 360) % 360 - 180 HeadingDiff = math.abs( HeadingDiff ) if HeadingDiff > 5 then HeadingSet = nil @@ -3654,19 +3563,19 @@ do -- SET_STATIC -- @return #number The maximum threatlevel function SET_STATIC:CalculateThreatLevelA2G() - local MaxThreatLevelA2G = 0 - local MaxThreatText = "" - for StaticName, StaticData in pairs( self:GetSet() ) do - local ThreatStatic = StaticData -- Wrapper.Static#STATIC - local ThreatLevelA2G, ThreatText = ThreatStatic:GetThreatLevel() - if ThreatLevelA2G > MaxThreatLevelA2G then - MaxThreatLevelA2G = ThreatLevelA2G - MaxThreatText = ThreatText + local MaxThreatLevelA2G = 0 + local MaxThreatText = "" + for StaticName, StaticData in pairs( self:GetSet() ) do + local ThreatStatic = StaticData -- Wrapper.Static#STATIC + local ThreatLevelA2G, ThreatText = ThreatStatic:GetThreatLevel() + if ThreatLevelA2G > MaxThreatLevelA2G then + MaxThreatLevelA2G = ThreatLevelA2G + MaxThreatText = ThreatText + end end - end - self:F( { MaxThreatLevelA2G = MaxThreatLevelA2G, MaxThreatText = MaxThreatText } ) - return MaxThreatLevelA2G, MaxThreatText + self:F( { MaxThreatLevelA2G = MaxThreatLevelA2G, MaxThreatText = MaxThreatText } ) + return MaxThreatLevelA2G, MaxThreatText end @@ -3732,26 +3641,25 @@ do -- SET_STATIC end MStaticInclude = MStaticInclude and MStaticPrefix end - + if self.Filter.Zones then local MStaticZone = false for ZoneName, Zone in pairs( self.Filter.Zones ) do self:T3( "Zone:", ZoneName ) - if MStatic and MStatic:IsInZone(Zone) then + if MStatic and MStatic:IsInZone( Zone ) then MStaticZone = true end end MStaticInclude = MStaticInclude and MStaticZone end - + self:T2( MStaticInclude ) return MStaticInclude end - --- Retrieve the type names of the @{Static}s in the SET, delimited by an optional delimiter. -- @param #SET_STATIC self - -- @param #string Delimiter (optional) The delimiter, which is default a comma. + -- @param #string Delimiter (Optional) The delimiter, which is default a comma. -- @return #string The types of the @{Static}s delimited. function SET_STATIC:GetTypeNames( Delimiter ) @@ -3775,15 +3683,11 @@ do -- SET_STATIC end - do -- SET_CLIENT - --- @type SET_CLIENT -- @extends Core.Set#SET_BASE - - --- Mission designers can use the @{Core.Set#SET_CLIENT} class to build sets of units belonging to certain: -- -- * Coalitions @@ -3880,7 +3784,7 @@ do -- SET_CLIENT -- @return self function SET_CLIENT:AddClientsByName( AddClientNames ) - local AddClientNamesArray = ( type( AddClientNames ) == "table" ) and AddClientNames or { AddClientNames } + local AddClientNamesArray = (type( AddClientNames ) == "table") and AddClientNames or { AddClientNames } for AddClientID, AddClientName in pairs( AddClientNamesArray ) do self:Add( AddClientName, CLIENT:FindByName( AddClientName ) ) @@ -3895,7 +3799,7 @@ do -- SET_CLIENT -- @return self function SET_CLIENT:RemoveClientsByName( RemoveClientNames ) - local RemoveClientNamesArray = ( type( RemoveClientNames ) == "table" ) and RemoveClientNames or { RemoveClientNames } + local RemoveClientNamesArray = (type( RemoveClientNames ) == "table") and RemoveClientNames or { RemoveClientNames } for RemoveClientID, RemoveClientName in pairs( RemoveClientNamesArray ) do self:Remove( RemoveClientName.ClientName ) @@ -3904,7 +3808,6 @@ do -- SET_CLIENT return self end - --- Finds a Client based on the Client Name. -- @param #SET_CLIENT self -- @param #string ClientName @@ -3915,8 +3818,6 @@ do -- SET_CLIENT return ClientFound end - - --- Builds a set of clients of coalitions. -- Possible current coalitions are red, blue and neutral. -- @param #SET_CLIENT self @@ -3935,7 +3836,6 @@ do -- SET_CLIENT return self end - --- Builds a set of clients out of categories. -- Possible current categories are plane, helicopter, ground, ship. -- @param #SET_CLIENT self @@ -3954,7 +3854,6 @@ do -- SET_CLIENT return self end - --- Builds a set of clients of defined client types. -- Possible current types are those types known within DCS world. -- @param #SET_CLIENT self @@ -3973,7 +3872,6 @@ do -- SET_CLIENT return self end - --- Builds a set of clients of defined countries. -- Possible current countries are those known within DCS world. -- @param #SET_CLIENT self @@ -3992,7 +3890,6 @@ do -- SET_CLIENT return self end - --- Builds a set of CLIENTs that contain the given string in their unit/pilot name. -- **Attention!** Bad naming convention as this **does not** filter only **prefixes** but all clients that **contain** the string. -- @param #SET_CLIENT self @@ -4014,7 +3911,7 @@ do -- SET_CLIENT --- Builds a set of clients that are only active. -- Only the clients that are active will be included within the set. -- @param #SET_CLIENT self - -- @param #boolean Active (optional) Include only active clients to the set. + -- @param #boolean Active (Optional) Include only active clients to the set. -- Include inactive clients if you provide false. -- @return #SET_CLIENT self -- @usage @@ -4032,12 +3929,12 @@ do -- SET_CLIENT -- ClientSet = SET_CLIENT:New():FilterActive( false ):FilterCoalition( "blue" ):FilterOnce() -- function SET_CLIENT:FilterActive( Active ) - Active = Active or not ( Active == false ) + Active = Active or not (Active == false) self.Filter.Active = Active return self end - --- Builds a set of clients in zones. + --- Builds a set of clients in zones. -- @param #SET_CLIENT self -- @param #table Zones Table of Core.Zone#ZONE Zone objects, or a Core.Set#SET_ZONE -- @return #SET_TABLE self @@ -4048,13 +3945,13 @@ do -- SET_CLIENT local zones = {} if Zones.ClassName and Zones.ClassName == "SET_ZONE" then zones = Zones.Set - elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName ) then - self:E("***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!") - return self + elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName) then + self:E( "***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!" ) + return self else zones = Zones end - for _,Zone in pairs( zones ) do + for _, Zone in pairs( zones ) do local zonename = Zone:GetName() self.Filter.Zones[zonename] = Zone end @@ -4155,7 +4052,7 @@ do -- SET_CLIENT return self end - + --- Iterate the SET_CLIENT and count alive units. -- @param #SET_CLIENT self -- @return #number count @@ -4164,7 +4061,7 @@ do -- SET_CLIENT local Set = self:GetSet() local CountU = 0 - for UnitID, UnitData in pairs(Set) do -- For each GROUP in SET_GROUP + for UnitID, UnitData in pairs( Set ) do -- For each GROUP in SET_GROUP if UnitData and UnitData:IsAlive() then CountU = CountU + 1 end @@ -4173,7 +4070,7 @@ do -- SET_CLIENT return CountU end - + --- -- @param #SET_CLIENT self -- @param Wrapper.Client#CLIENT MClient @@ -4188,7 +4085,7 @@ do -- SET_CLIENT if self.Filter.Active ~= nil then local MClientActive = false - if self.Filter.Active == false or ( self.Filter.Active == true and MClient:IsActive() == true ) then + if self.Filter.Active == false or (self.Filter.Active == true and MClient:IsActive() == true) then MClientActive = true end MClientInclude = MClientInclude and MClientActive @@ -4235,7 +4132,7 @@ do -- SET_CLIENT if self.Filter.Countries then local MClientCountry = false for CountryID, CountryName in pairs( self.Filter.Countries ) do - local ClientCountryID = _DATABASE:GetCountryFromClientTemplate(MClientName) + local ClientCountryID = _DATABASE:GetCountryFromClientTemplate( MClientName ) self:T3( { "Country:", ClientCountryID, country.id[CountryName], CountryName } ) if country.id[CountryName] and country.id[CountryName] == ClientCountryID then MClientCountry = true @@ -4263,27 +4160,24 @@ do -- SET_CLIENT for ZoneName, Zone in pairs( self.Filter.Zones ) do self:T3( "Zone:", ZoneName ) local unit = MClient:GetClientGroupUnit() - if unit and unit:IsInZone(Zone) then + if unit and unit:IsInZone( Zone ) then MClientZone = true end end MClientInclude = MClientInclude and MClientZone end - + self:T2( MClientInclude ) return MClientInclude end end - do -- SET_PLAYER --- @type SET_PLAYER -- @extends Core.Set#SET_BASE - - --- Mission designers can use the @{Core.Set#SET_PLAYER} class to build sets of units belonging to alive players: -- -- ## SET_PLAYER constructor @@ -4348,7 +4242,6 @@ do -- SET_PLAYER }, } - --- Creates a new SET_PLAYER object, building a set of clients belonging to a coalitions, categories, countries, types or with defined prefix names. -- @param #SET_PLAYER self -- @return #SET_PLAYER @@ -4368,7 +4261,7 @@ do -- SET_PLAYER -- @return self function SET_PLAYER:AddClientsByName( AddClientNames ) - local AddClientNamesArray = ( type( AddClientNames ) == "table" ) and AddClientNames or { AddClientNames } + local AddClientNamesArray = (type( AddClientNames ) == "table") and AddClientNames or { AddClientNames } for AddClientID, AddClientName in pairs( AddClientNamesArray ) do self:Add( AddClientName, CLIENT:FindByName( AddClientName ) ) @@ -4383,7 +4276,7 @@ do -- SET_PLAYER -- @return self function SET_PLAYER:RemoveClientsByName( RemoveClientNames ) - local RemoveClientNamesArray = ( type( RemoveClientNames ) == "table" ) and RemoveClientNames or { RemoveClientNames } + local RemoveClientNamesArray = (type( RemoveClientNames ) == "table") and RemoveClientNames or { RemoveClientNames } for RemoveClientID, RemoveClientName in pairs( RemoveClientNamesArray ) do self:Remove( RemoveClientName.ClientName ) @@ -4392,7 +4285,6 @@ do -- SET_PLAYER return self end - --- Finds a Client based on the Player Name. -- @param #SET_PLAYER self -- @param #string PlayerName @@ -4403,8 +4295,6 @@ do -- SET_PLAYER return ClientFound end - - --- Builds a set of clients of coalitions joined by specific players. -- Possible current coalitions are red, blue and neutral. -- @param #SET_PLAYER self @@ -4422,7 +4312,7 @@ do -- SET_PLAYER end return self end - + --- Builds a set of players in zones. -- @param #SET_PLAYER self -- @param #table Zones Table of Core.Zone#ZONE Zone objects, or a Core.Set#SET_ZONE @@ -4434,19 +4324,18 @@ do -- SET_PLAYER local zones = {} if Zones.ClassName and Zones.ClassName == "SET_ZONE" then zones = Zones.Set - elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName ) then - self:E("***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!") - return self + elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName) then + self:E( "***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!" ) + return self else zones = Zones end - for _,Zone in pairs( zones ) do + for _, Zone in pairs( zones ) do local zonename = Zone:GetName() self.Filter.Zones[zonename] = Zone end return self end - --- Builds a set of clients out of categories joined by players. -- Possible current categories are plane, helicopter, ground, ship. @@ -4466,7 +4355,6 @@ do -- SET_PLAYER return self end - --- Builds a set of clients of defined client types joined by players. -- Possible current types are those types known within DCS world. -- @param #SET_PLAYER self @@ -4485,7 +4373,6 @@ do -- SET_PLAYER return self end - --- Builds a set of clients of defined countries. -- Possible current countries are those known within DCS world. -- @param #SET_PLAYER self @@ -4504,7 +4391,6 @@ do -- SET_PLAYER return self end - --- Builds a set of PLAYERs that contain the given string in their unit/pilot name. -- **Attention!** Bad naming convention as this **does not** filter only **prefixes** but all player clients that **contain** the string. -- @param #SET_PLAYER self @@ -4523,9 +4409,6 @@ do -- SET_PLAYER return self end - - - --- Starts the filtering. -- @param #SET_PLAYER self -- @return #SET_PLAYER self @@ -4674,7 +4557,7 @@ do -- SET_PLAYER if self.Filter.Countries then local MClientCountry = false for CountryID, CountryName in pairs( self.Filter.Countries ) do - local ClientCountryID = _DATABASE:GetCountryFromClientTemplate(MClientName) + local ClientCountryID = _DATABASE:GetCountryFromClientTemplate( MClientName ) self:T3( { "Country:", ClientCountryID, country.id[CountryName], CountryName } ) if country.id[CountryName] and country.id[CountryName] == ClientCountryID then MClientCountry = true @@ -4696,26 +4579,25 @@ do -- SET_PLAYER MClientInclude = MClientInclude and MClientPrefix end end - + if self.Filter.Zones then local MClientZone = false for ZoneName, Zone in pairs( self.Filter.Zones ) do self:T3( "Zone:", ZoneName ) local unit = MClient:GetClientGroupUnit() - if unit and unit:IsInZone(Zone) then + if unit and unit:IsInZone( Zone ) then MClientZone = true end end MClientInclude = MClientInclude and MClientZone end - + self:T2( MClientInclude ) return MClientInclude end end - do -- SET_AIRBASE --- @type SET_AIRBASE @@ -4777,7 +4659,6 @@ do -- SET_AIRBASE }, } - --- Creates a new SET_AIRBASE object, building a set of airbases belonging to a coalitions and categories. -- @param #SET_AIRBASE self -- @return #SET_AIRBASE self @@ -4808,7 +4689,7 @@ do -- SET_AIRBASE -- @return self function SET_AIRBASE:AddAirbasesByName( AddAirbaseNames ) - local AddAirbaseNamesArray = ( type( AddAirbaseNames ) == "table" ) and AddAirbaseNames or { AddAirbaseNames } + local AddAirbaseNamesArray = (type( AddAirbaseNames ) == "table") and AddAirbaseNames or { AddAirbaseNames } for AddAirbaseID, AddAirbaseName in pairs( AddAirbaseNamesArray ) do self:Add( AddAirbaseName, AIRBASE:FindByName( AddAirbaseName ) ) @@ -4823,7 +4704,7 @@ do -- SET_AIRBASE -- @return self function SET_AIRBASE:RemoveAirbasesByName( RemoveAirbaseNames ) - local RemoveAirbaseNamesArray = ( type( RemoveAirbaseNames ) == "table" ) and RemoveAirbaseNames or { RemoveAirbaseNames } + local RemoveAirbaseNamesArray = (type( RemoveAirbaseNames ) == "table") and RemoveAirbaseNames or { RemoveAirbaseNames } for RemoveAirbaseID, RemoveAirbaseName in pairs( RemoveAirbaseNamesArray ) do self:Remove( RemoveAirbaseName ) @@ -4832,7 +4713,6 @@ do -- SET_AIRBASE return self end - --- Finds a Airbase based on the Airbase Name. -- @param #SET_AIRBASE self -- @param #string AirbaseName @@ -4843,7 +4723,6 @@ do -- SET_AIRBASE return AirbaseFound end - --- Finds an Airbase in range of a coordinate. -- @param #SET_AIRBASE self -- @param Core.Point#COORDINATE Coordinate @@ -4858,7 +4737,7 @@ do -- SET_AIRBASE local AirbaseCoordinate = AirbaseObject:GetCoordinate() local Distance = Coordinate:Get2DDistance( AirbaseCoordinate ) - self:F({Distance=Distance}) + self:F( { Distance = Distance } ) if Distance <= Range then AirbaseFound = AirbaseObject @@ -4870,7 +4749,6 @@ do -- SET_AIRBASE return AirbaseFound end - --- Finds a random Airbase in the set. -- @param #SET_AIRBASE self -- @return Wrapper.Airbase#AIRBASE The found Airbase. @@ -4882,8 +4760,6 @@ do -- SET_AIRBASE return RandomAirbase end - - --- Builds a set of airbases of coalitions. -- Possible current coalitions are red, blue and neutral. -- @param #SET_AIRBASE self @@ -4902,7 +4778,6 @@ do -- SET_AIRBASE return self end - --- Builds a set of airbases out of categories. -- Possible current categories are plane, helicopter, ground, ship. -- @param #SET_AIRBASE self @@ -4929,8 +4804,8 @@ do -- SET_AIRBASE if _DATABASE then -- We use the BaseCaptured event, which is generated by DCS when a base got captured. - self:HandleEvent(EVENTS.BaseCaptured) - self:HandleEvent(EVENTS.Dead) + self:HandleEvent( EVENTS.BaseCaptured ) + self:HandleEvent( EVENTS.Dead ) -- We initialize the first set. for ObjectName, Object in pairs( self.Database ) do @@ -4948,7 +4823,7 @@ do -- SET_AIRBASE --- Base capturing event. -- @param #SET_AIRBASE self -- @param Core.Event#EVENT EventData - function SET_AIRBASE:OnEventBaseCaptured(EventData) + function SET_AIRBASE:OnEventBaseCaptured( EventData ) -- When a base got captured, we reevaluate the set. for ObjectName, Object in pairs( self.Database ) do @@ -4966,17 +4841,16 @@ do -- SET_AIRBASE --- Dead event. -- @param #SET_AIRBASE self -- @param Core.Event#EVENT EventData - function SET_AIRBASE:OnEventDead(EventData) + function SET_AIRBASE:OnEventDead( EventData ) - local airbaseName, airbase=self:FindInDatabase(EventData) + local airbaseName, airbase = self:FindInDatabase( EventData ) if airbase and (airbase:IsShip() or airbase:IsHelipad()) then - self:RemoveAirbasesByName(airbaseName) + self:RemoveAirbasesByName( airbaseName ) end end - --- Handles the Database to check on an event (birth) that the Object was added in the Database. -- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event! -- @param #SET_AIRBASE self @@ -5022,8 +4896,6 @@ do -- SET_AIRBASE return NearestAirbase end - - --- -- @param #SET_AIRBASE self -- @param Wrapper.Airbase#AIRBASE MAirbase @@ -5069,7 +4941,6 @@ do -- SET_AIRBASE end - do -- SET_CARGO --- @type SET_CARGO @@ -5134,40 +5005,37 @@ do -- SET_CARGO }, } - --- Creates a new SET_CARGO object, building a set of cargos belonging to a coalitions and categories. -- @param #SET_CARGO self -- @return #SET_CARGO -- @usage -- -- Define a new SET_CARGO Object. The DatabaseSet will contain a reference to all Cargos. -- DatabaseSet = SET_CARGO:New() - function SET_CARGO:New() --R2.1 + function SET_CARGO:New() -- R2.1 -- Inherits from BASE local self = BASE:Inherit( self, SET_BASE:New( _DATABASE.CARGOS ) ) -- #SET_CARGO return self end - --- (R2.1) Add CARGO to SET_CARGO. -- @param Core.Set#SET_CARGO self -- @param Cargo.Cargo#CARGO Cargo A single cargo. -- @return Core.Set#SET_CARGO self - function SET_CARGO:AddCargo( Cargo ) --R2.4 + function SET_CARGO:AddCargo( Cargo ) -- R2.4 self:Add( Cargo:GetName(), Cargo ) return self end - --- (R2.1) Add CARGOs to SET_CARGO. -- @param Core.Set#SET_CARGO self -- @param #string AddCargoNames A single name or an array of CARGO names. -- @return Core.Set#SET_CARGO self - function SET_CARGO:AddCargosByName( AddCargoNames ) --R2.1 + function SET_CARGO:AddCargosByName( AddCargoNames ) -- R2.1 - local AddCargoNamesArray = ( type( AddCargoNames ) == "table" ) and AddCargoNames or { AddCargoNames } + local AddCargoNamesArray = (type( AddCargoNames ) == "table") and AddCargoNames or { AddCargoNames } for AddCargoID, AddCargoName in pairs( AddCargoNamesArray ) do self:Add( AddCargoName, CARGO:FindByName( AddCargoName ) ) @@ -5180,9 +5048,9 @@ do -- SET_CARGO -- @param Core.Set#SET_CARGO self -- @param Wrapper.Cargo#CARGO RemoveCargoNames A single name or an array of CARGO names. -- @return Core.Set#SET_CARGO self - function SET_CARGO:RemoveCargosByName( RemoveCargoNames ) --R2.1 + function SET_CARGO:RemoveCargosByName( RemoveCargoNames ) -- R2.1 - local RemoveCargoNamesArray = ( type( RemoveCargoNames ) == "table" ) and RemoveCargoNames or { RemoveCargoNames } + local RemoveCargoNamesArray = (type( RemoveCargoNames ) == "table") and RemoveCargoNames or { RemoveCargoNames } for RemoveCargoID, RemoveCargoName in pairs( RemoveCargoNamesArray ) do self:Remove( RemoveCargoName.CargoName ) @@ -5191,25 +5059,22 @@ do -- SET_CARGO return self end - --- (R2.1) Finds a Cargo based on the Cargo Name. -- @param #SET_CARGO self -- @param #string CargoName -- @return Wrapper.Cargo#CARGO The found Cargo. - function SET_CARGO:FindCargo( CargoName ) --R2.1 + function SET_CARGO:FindCargo( CargoName ) -- R2.1 local CargoFound = self.Set[CargoName] return CargoFound end - - --- (R2.1) Builds a set of cargos of coalitions. -- Possible current coalitions are red, blue and neutral. -- @param #SET_CARGO self -- @param #string Coalitions Can take the following values: "red", "blue", "neutral". -- @return #SET_CARGO self - function SET_CARGO:FilterCoalitions( Coalitions ) --R2.1 + function SET_CARGO:FilterCoalitions( Coalitions ) -- R2.1 if not self.Filter.Coalitions then self.Filter.Coalitions = {} end @@ -5227,7 +5092,7 @@ do -- SET_CARGO -- @param #SET_CARGO self -- @param #string Types Can take those type strings known within DCS world. -- @return #SET_CARGO self - function SET_CARGO:FilterTypes( Types ) --R2.1 + function SET_CARGO:FilterTypes( Types ) -- R2.1 if not self.Filter.Types then self.Filter.Types = {} end @@ -5240,13 +5105,12 @@ do -- SET_CARGO return self end - --- (R2.1) Builds a set of cargos of defined countries. -- Possible current countries are those known within DCS world. -- @param #SET_CARGO self -- @param #string Countries Can take those country strings known within DCS world. -- @return #SET_CARGO self - function SET_CARGO:FilterCountries( Countries ) --R2.1 + function SET_CARGO:FilterCountries( Countries ) -- R2.1 if not self.Filter.Countries then self.Filter.Countries = {} end @@ -5259,13 +5123,12 @@ do -- SET_CARGO return self end - --- Builds a set of CARGOs that contain a given string in their name. -- **Attention!** Bad naming convention as this **does not** filter only **prefixes** but all cargos that **contain** the string. -- @param #SET_CARGO self -- @param #string Prefixes The string pattern(s) that need to be in the cargo name. Can also be passed as a `#table` of strings. -- @return #SET_CARGO self - function SET_CARGO:FilterPrefixes( Prefixes ) --R2.1 + function SET_CARGO:FilterPrefixes( Prefixes ) -- R2.1 if not self.Filter.CargoPrefixes then self.Filter.CargoPrefixes = {} end @@ -5278,12 +5141,10 @@ do -- SET_CARGO return self end - - --- (R2.1) Starts the filtering. -- @param #SET_CARGO self -- @return #SET_CARGO self - function SET_CARGO:FilterStart() --R2.1 + function SET_CARGO:FilterStart() -- R2.1 if _DATABASE then self:_FilterStart() @@ -5305,14 +5166,13 @@ do -- SET_CARGO return self end - --- (R2.1) Handles the Database to check on an event (birth) that the Object was added in the Database. -- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event! -- @param #SET_CARGO self -- @param Core.Event#EVENTDATA Event -- @return #string The name of the CARGO -- @return #table The CARGO - function SET_CARGO:AddInDatabase( Event ) --R2.1 + function SET_CARGO:AddInDatabase( Event ) -- R2.1 self:F3( { Event } ) return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] @@ -5324,7 +5184,7 @@ do -- SET_CARGO -- @param Core.Event#EVENTDATA Event -- @return #string The name of the CARGO -- @return #table The CARGO - function SET_CARGO:FindInDatabase( Event ) --R2.1 + function SET_CARGO:FindInDatabase( Event ) -- R2.1 self:F3( { Event } ) return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] @@ -5334,7 +5194,7 @@ do -- SET_CARGO -- @param #SET_CARGO self -- @param #function IteratorFunction The function that will be called when there is an alive CARGO in the SET_CARGO. The function needs to accept a CARGO parameter. -- @return #SET_CARGO self - function SET_CARGO:ForEachCargo( IteratorFunction, ... ) --R2.1 + function SET_CARGO:ForEachCargo( IteratorFunction, ... ) -- R2.1 self:F2( arg ) self:ForEach( IteratorFunction, arg, self:GetSet() ) @@ -5346,7 +5206,7 @@ do -- SET_CARGO -- @param #SET_CARGO self -- @param Core.Point#POINT_VEC2 PointVec2 A @{Core.Point#POINT_VEC2} object from where to evaluate the closest @{Cargo.Cargo#CARGO}. -- @return Wrapper.Cargo#CARGO The closest @{Cargo.Cargo#CARGO}. - function SET_CARGO:FindNearestCargoFromPointVec2( PointVec2 ) --R2.1 + function SET_CARGO:FindNearestCargoFromPointVec2( PointVec2 ) -- R2.1 self:F2( PointVec2 ) local NearestCargo = self:FindNearestObjectFromPointVec2( PointVec2 ) @@ -5381,7 +5241,6 @@ do -- SET_CARGO return FirstCargo end - --- Iterate the SET_CARGO while identifying the first @{Cargo.Cargo#CARGO} that is UnLoaded. -- @param #SET_CARGO self -- @return Cargo.Cargo#CARGO The first @{Cargo.Cargo#CARGO}. @@ -5390,7 +5249,6 @@ do -- SET_CARGO return FirstCargo end - --- Iterate the SET_CARGO while identifying the first @{Cargo.Cargo#CARGO} that is UnLoaded and not Deployed. -- @param #SET_CARGO self -- @return Cargo.Cargo#CARGO The first @{Cargo.Cargo#CARGO}. @@ -5399,7 +5257,6 @@ do -- SET_CARGO return FirstCargo end - --- Iterate the SET_CARGO while identifying the first @{Cargo.Cargo#CARGO} that is Loaded. -- @param #SET_CARGO self -- @return Cargo.Cargo#CARGO The first @{Cargo.Cargo#CARGO}. @@ -5408,7 +5265,6 @@ do -- SET_CARGO return FirstCargo end - --- Iterate the SET_CARGO while identifying the first @{Cargo.Cargo#CARGO} that is Deployed. -- @param #SET_CARGO self -- @return Cargo.Cargo#CARGO The first @{Cargo.Cargo#CARGO}. @@ -5417,14 +5273,11 @@ do -- SET_CARGO return FirstCargo end - - - --- (R2.1) -- @param #SET_CARGO self -- @param AI.AI_Cargo#AI_CARGO MCargo -- @return #SET_CARGO self - function SET_CARGO:IsIncludeObject( MCargo ) --R2.1 + function SET_CARGO:IsIncludeObject( MCargo ) -- R2.1 self:F2( MCargo ) local MCargoInclude = true @@ -5477,13 +5330,13 @@ do -- SET_CARGO --- (R2.1) Handles the OnEventNewCargo event for the Set. -- @param #SET_CARGO self -- @param Core.Event#EVENTDATA EventData - function SET_CARGO:OnEventNewCargo( EventData ) --R2.1 + function SET_CARGO:OnEventNewCargo( EventData ) -- R2.1 self:F( { "New Cargo", EventData } ) if EventData.Cargo then if EventData.Cargo and self:IsIncludeObject( EventData.Cargo ) then - self:Add( EventData.Cargo.Name , EventData.Cargo ) + self:Add( EventData.Cargo.Name, EventData.Cargo ) end end end @@ -5491,20 +5344,20 @@ do -- SET_CARGO --- (R2.1) Handles the OnDead or OnCrash event for alive units set. -- @param #SET_CARGO self -- @param Core.Event#EVENTDATA EventData - function SET_CARGO:OnEventDeleteCargo( EventData ) --R2.1 + function SET_CARGO:OnEventDeleteCargo( EventData ) -- R2.1 self:F3( { EventData } ) if EventData.Cargo then local Cargo = _DATABASE:FindCargo( EventData.Cargo.Name ) if Cargo and Cargo.Name then - -- When cargo was deleted, it may probably be because of an S_EVENT_DEAD. - -- However, in the loading logic, an S_EVENT_DEAD is also generated after a Destroy() call. - -- And this is a problem because it will remove all entries from the SET_CARGOs. - -- To prevent this from happening, the Cargo object has a flag NoDestroy. - -- When true, the SET_CARGO won't Remove the Cargo object from the set. - -- This flag is switched off after the event handlers have been called in the EVENT class. - self:F( { CargoNoDestroy=Cargo.NoDestroy } ) + -- When cargo was deleted, it may probably be because of an S_EVENT_DEAD. + -- However, in the loading logic, an S_EVENT_DEAD is also generated after a Destroy() call. + -- And this is a problem because it will remove all entries from the SET_CARGOs. + -- To prevent this from happening, the Cargo object has a flag NoDestroy. + -- When true, the SET_CARGO won't Remove the Cargo object from the set. + -- This flag is switched off after the event handlers have been called in the EVENT class. + self:F( { CargoNoDestroy = Cargo.NoDestroy } ) if Cargo.NoDestroy then else self:Remove( Cargo.Name ) @@ -5515,7 +5368,6 @@ do -- SET_CARGO end - do -- SET_ZONE --- @type SET_ZONE @@ -5561,11 +5413,9 @@ do -- SET_ZONE Filter = { Prefixes = nil, }, - FilterMeta = { - }, + FilterMeta = {}, } - --- Creates a new SET_ZONE object, building a set of zones. -- @param #SET_ZONE self -- @return #SET_ZONE self @@ -5585,7 +5435,7 @@ do -- SET_ZONE -- @return self function SET_ZONE:AddZonesByName( AddZoneNames ) - local AddZoneNamesArray = ( type( AddZoneNames ) == "table" ) and AddZoneNames or { AddZoneNames } + local AddZoneNamesArray = (type( AddZoneNames ) == "table") and AddZoneNames or { AddZoneNames } for AddAirbaseID, AddZoneName in pairs( AddZoneNamesArray ) do self:Add( AddZoneName, ZONE:FindByName( AddZoneName ) ) @@ -5605,14 +5455,13 @@ do -- SET_ZONE return self end - --- Remove ZONEs from SET_ZONE. -- @param Core.Set#SET_ZONE self -- @param Core.Zone#ZONE_BASE RemoveZoneNames A single name or an array of ZONE_BASE names. -- @return self function SET_ZONE:RemoveZonesByName( RemoveZoneNames ) - local RemoveZoneNamesArray = ( type( RemoveZoneNames ) == "table" ) and RemoveZoneNames or { RemoveZoneNames } + local RemoveZoneNamesArray = (type( RemoveZoneNames ) == "table") and RemoveZoneNames or { RemoveZoneNames } for RemoveZoneID, RemoveZoneName in pairs( RemoveZoneNamesArray ) do self:Remove( RemoveZoneName ) @@ -5621,7 +5470,6 @@ do -- SET_ZONE return self end - --- Finds a Zone based on the Zone Name. -- @param #SET_ZONE self -- @param #string ZoneName @@ -5632,14 +5480,13 @@ do -- SET_ZONE return ZoneFound end - --- Get a random zone from the set. -- @param #SET_ZONE self -- @param #number margin Number of tries to find a zone -- @return Core.Zone#ZONE_BASE The random Zone. -- @return #nil if no zone in the collection. - function SET_ZONE:GetRandomZone(margin) - + function SET_ZONE:GetRandomZone( margin ) + local margin = margin or 100 if self:Count() ~= 0 then @@ -5662,7 +5509,6 @@ do -- SET_ZONE return nil end - --- Set a zone probability. -- @param #SET_ZONE self -- @param #string ZoneName The name of the zone. @@ -5671,9 +5517,6 @@ do -- SET_ZONE Zone:SetZoneProbability( ZoneProbability ) end - - - --- Builds a set of ZONEs that contain the given string in their name. -- **ATTENTION!** Bad naming convention as this **does not** filter only **prefixes** but all zones that **contain** the string. -- @param #SET_ZONE self @@ -5692,7 +5535,6 @@ do -- SET_ZONE return self end - --- Starts the filtering. -- @param #SET_ZONE self -- @return #SET_ZONE self @@ -5763,7 +5605,6 @@ do -- SET_ZONE return self end - --- -- @param #SET_ZONE self -- @param Core.Zone#ZONE_BASE MZone @@ -5796,13 +5637,13 @@ do -- SET_ZONE --- Handles the OnEventNewZone event for the Set. -- @param #SET_ZONE self -- @param Core.Event#EVENTDATA EventData - function SET_ZONE:OnEventNewZone( EventData ) --R2.1 + function SET_ZONE:OnEventNewZone( EventData ) -- R2.1 self:F( { "New Zone", EventData } ) if EventData.Zone then if EventData.Zone and self:IsIncludeObject( EventData.Zone ) then - self:Add( EventData.Zone.ZoneName , EventData.Zone ) + self:Add( EventData.Zone.ZoneName, EventData.Zone ) end end end @@ -5810,20 +5651,20 @@ do -- SET_ZONE --- Handles the OnDead or OnCrash event for alive units set. -- @param #SET_ZONE self -- @param Core.Event#EVENTDATA EventData - function SET_ZONE:OnEventDeleteZone( EventData ) --R2.1 + function SET_ZONE:OnEventDeleteZone( EventData ) -- R2.1 self:F3( { EventData } ) if EventData.Zone then local Zone = _DATABASE:FindZone( EventData.Zone.ZoneName ) if Zone and Zone.ZoneName then - -- When cargo was deleted, it may probably be because of an S_EVENT_DEAD. - -- However, in the loading logic, an S_EVENT_DEAD is also generated after a Destroy() call. - -- And this is a problem because it will remove all entries from the SET_ZONEs. - -- To prevent this from happening, the Zone object has a flag NoDestroy. - -- When true, the SET_ZONE won't Remove the Zone object from the set. - -- This flag is switched off after the event handlers have been called in the EVENT class. - self:F( { ZoneNoDestroy=Zone.NoDestroy } ) + -- When cargo was deleted, it may probably be because of an S_EVENT_DEAD. + -- However, in the loading logic, an S_EVENT_DEAD is also generated after a Destroy() call. + -- And this is a problem because it will remove all entries from the SET_ZONEs. + -- To prevent this from happening, the Zone object has a flag NoDestroy. + -- When true, the SET_ZONE won't Remove the Zone object from the set. + -- This flag is switched off after the event handlers have been called in the EVENT class. + self:F( { ZoneNoDestroy = Zone.NoDestroy } ) if Zone.NoDestroy then else self:Remove( Zone.ZoneName ) @@ -5898,11 +5739,10 @@ do -- SET_ZONE_GOAL Filter = { Prefixes = nil, }, - FilterMeta = { + FilterMeta = { }, } - --- Creates a new SET_ZONE_GOAL object, building a set of zones. -- @param #SET_ZONE_GOAL self -- @return #SET_ZONE_GOAL self @@ -5927,14 +5767,13 @@ do -- SET_ZONE_GOAL return self end - --- Remove ZONEs from SET_ZONE_GOAL. -- @param Core.Set#SET_ZONE_GOAL self -- @param Core.Zone#ZONE_BASE RemoveZoneNames A single name or an array of ZONE_BASE names. -- @return self function SET_ZONE_GOAL:RemoveZonesByName( RemoveZoneNames ) - local RemoveZoneNamesArray = ( type( RemoveZoneNames ) == "table" ) and RemoveZoneNames or { RemoveZoneNames } + local RemoveZoneNamesArray = (type( RemoveZoneNames ) == "table") and RemoveZoneNames or { RemoveZoneNames } for RemoveZoneID, RemoveZoneName in pairs( RemoveZoneNamesArray ) do self:Remove( RemoveZoneName ) @@ -5943,7 +5782,6 @@ do -- SET_ZONE_GOAL return self end - --- Finds a Zone based on the Zone Name. -- @param #SET_ZONE_GOAL self -- @param #string ZoneName @@ -5954,7 +5792,6 @@ do -- SET_ZONE_GOAL return ZoneFound end - --- Get a random zone from the set. -- @param #SET_ZONE_GOAL self -- @return Core.Zone#ZONE_BASE The random Zone. @@ -5980,7 +5817,6 @@ do -- SET_ZONE_GOAL return nil end - --- Set a zone probability. -- @param #SET_ZONE_GOAL self -- @param #string ZoneName The name of the zone. @@ -5989,9 +5825,6 @@ do -- SET_ZONE_GOAL Zone:SetZoneProbability( ZoneProbability ) end - - - --- Builds a set of ZONE_GOALs that contain the given string in their name. -- **ATTENTION!** Bad naming convention as this **does not** filter only **prefixes** but all zones that **contain** the string. -- @param #SET_ZONE_GOAL self @@ -6010,7 +5843,6 @@ do -- SET_ZONE_GOAL return self end - --- Starts the filtering. -- @param #SET_ZONE_GOAL self -- @return #SET_ZONE_GOAL self @@ -6081,7 +5913,6 @@ do -- SET_ZONE_GOAL return self end - --- -- @param #SET_ZONE_GOAL self -- @param Core.Zone#ZONE_BASE MZone @@ -6123,7 +5954,7 @@ do -- SET_ZONE_GOAL if EventData.ZoneGoal then if EventData.ZoneGoal and self:IsIncludeObject( EventData.ZoneGoal ) then self:T( { "Adding Zone Capture Coalition", EventData.ZoneGoal.ZoneName, EventData.ZoneGoal } ) - self:Add( EventData.ZoneGoal.ZoneName , EventData.ZoneGoal ) + self:Add( EventData.ZoneGoal.ZoneName, EventData.ZoneGoal ) end end end @@ -6131,20 +5962,20 @@ do -- SET_ZONE_GOAL --- Handles the OnDead or OnCrash event for alive units set. -- @param #SET_ZONE_GOAL self -- @param Core.Event#EVENTDATA EventData - function SET_ZONE_GOAL:OnEventDeleteZoneGoal( EventData ) --R2.1 + function SET_ZONE_GOAL:OnEventDeleteZoneGoal( EventData ) -- R2.1 self:F3( { EventData } ) if EventData.ZoneGoal then local Zone = _DATABASE:FindZone( EventData.ZoneGoal.ZoneName ) if Zone and Zone.ZoneName then - -- When cargo was deleted, it may probably be because of an S_EVENT_DEAD. - -- However, in the loading logic, an S_EVENT_DEAD is also generated after a Destroy() call. - -- And this is a problem because it will remove all entries from the SET_ZONE_GOALs. - -- To prevent this from happening, the Zone object has a flag NoDestroy. - -- When true, the SET_ZONE_GOAL won't Remove the Zone object from the set. - -- This flag is switched off after the event handlers have been called in the EVENT class. - self:F( { ZoneNoDestroy=Zone.NoDestroy } ) + -- When cargo was deleted, it may probably be because of an S_EVENT_DEAD. + -- However, in the loading logic, an S_EVENT_DEAD is also generated after a Destroy() call. + -- And this is a problem because it will remove all entries from the SET_ZONE_GOALs. + -- To prevent this from happening, the Zone object has a flag NoDestroy. + -- When true, the SET_ZONE_GOAL won't Remove the Zone object from the set. + -- This flag is switched off after the event handlers have been called in the EVENT class. + self:F( { ZoneNoDestroy = Zone.NoDestroy } ) if Zone.NoDestroy then else self:Remove( Zone.ZoneName ) @@ -6174,8 +6005,6 @@ do -- SET_ZONE_GOAL end - - do -- SET_OPSGROUP --- @type SET_OPSGROUP @@ -6281,14 +6110,13 @@ do -- SET_OPSGROUP }, -- FilterMeta } - --- Creates a new SET_OPSGROUP object, building a set of groups belonging to a coalitions, categories, countries, types or with defined prefix names. -- @param #SET_OPSGROUP self -- @return #SET_OPSGROUP function SET_OPSGROUP:New() -- Inherit SET_BASE. - local self = BASE:Inherit(self, SET_BASE:New(_DATABASE.GROUPS)) -- #SET_OPSGROUP + local self = BASE:Inherit( self, SET_BASE:New( _DATABASE.GROUPS ) ) -- #SET_OPSGROUP -- Include non activated self:FilterActive( false ) @@ -6304,80 +6132,80 @@ do -- SET_OPSGROUP local AliveSet = SET_OPSGROUP:New() -- Clean the Set before returning with only the alive Groups. - for GroupName, GroupObject in pairs(self.Set) do - local GroupObject=GroupObject --Wrapper.Group#GROUP - - if GroupObject and GroupObject:IsAlive() then - AliveSet:Add(GroupName, GroupObject) + for GroupName, GroupObject in pairs( self.Set ) do + local GroupObject = GroupObject -- Wrapper.Group#GROUP + + if GroupObject and GroupObject:IsAlive() then + AliveSet:Add( GroupName, GroupObject ) end end return AliveSet.Set or {} end - + --- Adds a @{Core.Base#BASE} object in the @{Core.Set#SET_BASE}, using a given ObjectName as the index. -- @param #SET_BASE self -- @param #string ObjectName The name of the object. -- @param Core.Base#BASE Object The object itself. -- @return Core.Base#BASE The added BASE Object. - function SET_OPSGROUP:Add(ObjectName, Object) + function SET_OPSGROUP:Add( ObjectName, Object ) self:T( { ObjectName = ObjectName, Object = Object } ) -- Ensure that the existing element is removed from the Set before a new one is inserted to the Set if self.Set[ObjectName] then - self:Remove(ObjectName, true) + self:Remove( ObjectName, true ) end - - local object=nil --Ops.OpsGroup#OPSGROUP - if Object:IsInstanceOf("GROUP") then - + + local object = nil -- Ops.OpsGroup#OPSGROUP + if Object:IsInstanceOf( "GROUP" ) then + --- -- GROUP Object --- - + -- Fist, look up in the DATABASE if an OPSGROUP already exists. - object=_DATABASE:FindOpsGroup(ObjectName) - + object = _DATABASE:FindOpsGroup( ObjectName ) + if not object then - + if Object:IsShip() then - object=NAVYGROUP:New(Object) + object = NAVYGROUP:New( Object ) elseif Object:IsGround() then - object=ARMYGROUP:New(Object) + object = ARMYGROUP:New( Object ) elseif Object:IsAir() then - object=FLIGHTGROUP:New(Object) + object = FLIGHTGROUP:New( Object ) else - env.error("ERROR: Unknown category of group object!") + env.error( "ERROR: Unknown category of group object!" ) end end - - elseif Object:IsInstanceOf("OPSGROUP") then + + elseif Object:IsInstanceOf( "OPSGROUP" ) then -- We already have an OPSGROUP. - object=Object + object = Object else - env.error("ERROR: Object must be a GROUP or OPSGROUP!") + env.error( "ERROR: Object must be a GROUP or OPSGROUP!" ) end - + -- Add object to set. - self.Set[ObjectName]=object + self.Set[ObjectName] = object -- Add Object name to Index. - table.insert(self.Index, ObjectName) + table.insert( self.Index, ObjectName ) -- Trigger Added event. - self:Added(ObjectName, object) - end + self:Added( ObjectName, object ) + end --- Add a GROUP or OPSGROUP object to the set. -- **NOTE** that an OPSGROUP is automatically created from the GROUP if it does not exist already. -- @param Core.Set#SET_OPSGROUP self -- @param Wrapper.Group#GROUP group The GROUP which should be added to the set. Can also be given as an #OPSGROUP object. -- @return Core.Set#SET_OPSGROUP self - function SET_OPSGROUP:AddGroup(group) - - local groupname=group:GetName() - - self:Add(groupname, group ) + function SET_OPSGROUP:AddGroup( group ) + + local groupname = group:GetName() + + self:Add( groupname, group ) return self end @@ -6388,10 +6216,10 @@ do -- SET_OPSGROUP -- @return Core.Set#SET_OPSGROUP self function SET_OPSGROUP:AddGroupsByName( AddGroupNames ) - local AddGroupNamesArray = ( type( AddGroupNames ) == "table" ) and AddGroupNames or { AddGroupNames } + local AddGroupNamesArray = (type( AddGroupNames ) == "table") and AddGroupNames or { AddGroupNames } for AddGroupID, AddGroupName in pairs( AddGroupNamesArray ) do - self:Add(AddGroupName, GROUP:FindByName(AddGroupName)) + self:Add( AddGroupName, GROUP:FindByName( AddGroupName ) ) end return self @@ -6403,7 +6231,7 @@ do -- SET_OPSGROUP -- @return Core.Set#SET_OPSGROUP self function SET_OPSGROUP:RemoveGroupsByName( RemoveGroupNames ) - local RemoveGroupNamesArray = ( type( RemoveGroupNames ) == "table" ) and RemoveGroupNames or { RemoveGroupNames } + local RemoveGroupNamesArray = (type( RemoveGroupNames ) == "table") and RemoveGroupNames or { RemoveGroupNames } for RemoveGroupID, RemoveGroupName in pairs( RemoveGroupNamesArray ) do self:Remove( RemoveGroupName ) @@ -6416,65 +6244,63 @@ do -- SET_OPSGROUP -- @param #SET_OPSGROUP self -- @param #string GroupName Name of the group. -- @return Ops.OpsGroup#OPSGROUP The found OPSGROUP (FLIGHTGROUP, ARMYGROUP or NAVYGROUP) or `#nil` if the group is not in the set. - function SET_OPSGROUP:FindGroup(GroupName) + function SET_OPSGROUP:FindGroup( GroupName ) local GroupFound = self.Set[GroupName] return GroupFound end - + --- Finds a FLIGHTGROUP based on the group name. -- @param #SET_OPSGROUP self -- @param #string GroupName Name of the group. -- @return Ops.FlightGroup#FLIGHTGROUP The found FLIGHTGROUP or `#nil` if the group is not in the set. - function SET_OPSGROUP:FindFlightGroup(GroupName) - local GroupFound = self:FindGroup(GroupName) + function SET_OPSGROUP:FindFlightGroup( GroupName ) + local GroupFound = self:FindGroup( GroupName ) return GroupFound end - + --- Finds a ARMYGROUP based on the group name. -- @param #SET_OPSGROUP self -- @param #string GroupName Name of the group. -- @return Ops.ArmyGroup#ARMYGROUP The found ARMYGROUP or `#nil` if the group is not in the set. - function SET_OPSGROUP:FindArmyGroup(GroupName) - local GroupFound = self:FindGroup(GroupName) + function SET_OPSGROUP:FindArmyGroup( GroupName ) + local GroupFound = self:FindGroup( GroupName ) return GroupFound - end - + end --- Finds a NAVYGROUP based on the group name. -- @param #SET_OPSGROUP self -- @param #string GroupName Name of the group. -- @return Ops.NavyGroup#NAVYGROUP The found NAVYGROUP or `#nil` if the group is not in the set. - function SET_OPSGROUP:FindNavyGroup(GroupName) - local GroupFound = self:FindGroup(GroupName) + function SET_OPSGROUP:FindNavyGroup( GroupName ) + local GroupFound = self:FindGroup( GroupName ) return GroupFound - end - + end + --- Builds a set of groups of coalitions. -- Possible current coalitions are red, blue and neutral. -- @param #SET_OPSGROUP self -- @param #string Coalitions Can take the following values: "red", "blue", "neutral" or combinations as a table, for example `{"red", "neutral"}`. -- @return #SET_OPSGROUP self - function SET_OPSGROUP:FilterCoalitions(Coalitions) - + function SET_OPSGROUP:FilterCoalitions( Coalitions ) + -- Create an empty set. if not self.Filter.Coalitions then - self.Filter.Coalitions={} + self.Filter.Coalitions = {} end - + -- Ensure we got a table. - if type(Coalitions)~="table" then - Coalitions = {Coalitions} + if type( Coalitions ) ~= "table" then + Coalitions = { Coalitions } end - + -- Set filter. for CoalitionID, Coalition in pairs( Coalitions ) do self.Filter.Coalitions[Coalition] = Coalition end - + return self end - --- Builds a set of groups out of categories. -- -- Possible current categories are: @@ -6488,19 +6314,19 @@ do -- SET_OPSGROUP -- @param #string Categories Can take the following values: "plane", "helicopter", "ground", "ship" or combinations as a table, for example `{"plane", "helicopter"}`. -- @return #SET_OPSGROUP self function SET_OPSGROUP:FilterCategories( Categories ) - + if not self.Filter.Categories then - self.Filter.Categories={} + self.Filter.Categories = {} end - - if type(Categories)~="table" then - Categories={Categories} + + if type( Categories ) ~= "table" then + Categories = { Categories } end - + for CategoryID, Category in pairs( Categories ) do self.Filter.Categories[Category] = Category end - + return self end @@ -6508,7 +6334,7 @@ do -- SET_OPSGROUP -- @param #SET_OPSGROUP self -- @return #SET_OPSGROUP self function SET_OPSGROUP:FilterCategoryGround() - self:FilterCategories("ground") + self:FilterCategories( "ground" ) return self end @@ -6516,23 +6342,23 @@ do -- SET_OPSGROUP -- @param #SET_OPSGROUP self -- @return #SET_OPSGROUP self function SET_OPSGROUP:FilterCategoryAirplane() - self:FilterCategories("plane") + self:FilterCategories( "plane" ) return self end - + --- Builds a set of groups out of aicraft category (planes and helicopters). -- @param #SET_OPSGROUP self -- @return #SET_OPSGROUP self function SET_OPSGROUP:FilterCategoryAircraft() - self:FilterCategories({"plane", "helicopter"}) + self:FilterCategories( { "plane", "helicopter" } ) return self - end + end --- Builds a set of groups out of helicopter category. -- @param #SET_OPSGROUP self -- @return #SET_OPSGROUP self function SET_OPSGROUP:FilterCategoryHelicopter() - self:FilterCategories("helicopter") + self:FilterCategories( "helicopter" ) return self end @@ -6540,7 +6366,7 @@ do -- SET_OPSGROUP -- @param #SET_OPSGROUP self -- @return #SET_OPSGROUP self function SET_OPSGROUP:FilterCategoryShip() - self:FilterCategories("ship") + self:FilterCategories( "ship" ) return self end @@ -6548,56 +6374,55 @@ do -- SET_OPSGROUP -- @param #SET_OPSGROUP self -- @param #string Countries Can take those country strings known within DCS world. -- @return #SET_OPSGROUP self - function SET_OPSGROUP:FilterCountries(Countries) - + function SET_OPSGROUP:FilterCountries( Countries ) + -- Create empty table if necessary. if not self.Filter.Countries then self.Filter.Countries = {} end - + -- Ensure input is a table. - if type(Countries)~="table" then - Countries={Countries} + if type( Countries ) ~= "table" then + Countries = { Countries } end - + -- Set filter. for CountryID, Country in pairs( Countries ) do self.Filter.Countries[Country] = Country end - + return self end - --- Builds a set of groups that contain the given string in their group name. -- **Attention!** Bad naming convention as this **does not** filter only **prefixes** but all groups that **contain** the string. -- @param #SET_OPSGROUP self -- @param #string Prefixes The string pattern(s) that needs to be contained in the group name. Can also be passed as a `#table` of strings. -- @return #SET_OPSGROUP self - function SET_OPSGROUP:FilterPrefixes(Prefixes) - + function SET_OPSGROUP:FilterPrefixes( Prefixes ) + -- Create emtpy table if necessary. if not self.Filter.GroupPrefixes then - self.Filter.GroupPrefixes={} + self.Filter.GroupPrefixes = {} end - + -- Ensure we have a table. - if type(Prefixes)~="table" then - Prefixes={Prefixes} + if type( Prefixes ) ~= "table" then + Prefixes = { Prefixes } end - + -- Set group prefixes. - for PrefixID, Prefix in pairs(Prefixes) do - self.Filter.GroupPrefixes[Prefix]=Prefix + for PrefixID, Prefix in pairs( Prefixes ) do + self.Filter.GroupPrefixes[Prefix] = Prefix end - + return self end --- Builds a set of groups that are only active. -- Only the groups that are active will be included within the set. -- @param #SET_OPSGROUP self - -- @param #boolean Active (optional) Include only active groups to the set. + -- @param #boolean Active (Optional) Include only active groups to the set. -- Include inactive groups if you provide false. -- @return #SET_OPSGROUP self -- @usage @@ -6615,12 +6440,11 @@ do -- SET_OPSGROUP -- GroupSet = SET_OPSGROUP:New():FilterActive( false ):FilterCoalition( "blue" ):FilterOnce() -- function SET_OPSGROUP:FilterActive( Active ) - Active = Active or not ( Active == false ) + Active = Active or not (Active == false) self.Filter.Active = Active return self end - --- Starts the filtering. -- @param #SET_OPSGROUP self -- @return #SET_OPSGROUP self @@ -6636,21 +6460,21 @@ do -- SET_OPSGROUP return self end - + --- Activate late activated groups in the set. -- @param #SET_OPSGROUP self -- @param #number Delay Delay in seconds. -- @return #SET_OPSGROUP self - function SET_OPSGROUP:Activate(Delay) + function SET_OPSGROUP:Activate( Delay ) local Set = self:GetSet() - for GroupID, GroupData in pairs(Set) do - local group=GroupData --Ops.OpsGroup#OPSGROUP - if group and group:IsAlive()==false then - group:Activate(Delay) + for GroupID, GroupData in pairs( Set ) do + local group = GroupData -- Ops.OpsGroup#OPSGROUP + if group and group:IsAlive() == false then + group:Activate( Delay ) end end return self - end + end --- Handles the OnDead or OnCrash event for alive groups set. -- Note: The GROUP object in the SET_OPSGROUP collection will only be removed if the last unit is destroyed of the GROUP. @@ -6676,13 +6500,13 @@ do -- SET_OPSGROUP -- @return #string The name of the GROUP -- @return #table The GROUP function SET_OPSGROUP:AddInDatabase( Event ) - - if Event.IniObjectCategory==1 then - + + if Event.IniObjectCategory == 1 then + if not self.Database[Event.IniDCSGroupName] then self.Database[Event.IniDCSGroupName] = GROUP:Register( Event.IniDCSGroupName ) end - + end return Event.IniDCSGroupName, self.Database[Event.IniDCSGroupName] @@ -6694,7 +6518,7 @@ do -- SET_OPSGROUP -- @param Core.Event#EVENTDATA Event Event data table. -- @return #string The name of the GROUP -- @return #table The GROUP - function SET_OPSGROUP:FindInDatabase(Event) + function SET_OPSGROUP:FindInDatabase( Event ) return Event.IniDCSGroupName, self.Database[Event.IniDCSGroupName] end @@ -6705,7 +6529,7 @@ do -- SET_OPSGROUP -- @return #SET_OPSGROUP self function SET_OPSGROUP:ForEachGroup( IteratorFunction, ... ) - self:ForEach(IteratorFunction, arg, self:GetSet()) + self:ForEach( IteratorFunction, arg, self:GetSet() ) return self end @@ -6714,48 +6538,48 @@ do -- SET_OPSGROUP -- @param #SET_OPSGROUP self -- @param Wrapper.Group#GROUP MGroup The group that is checked for inclusion. -- @return #SET_OPSGROUP self - function SET_OPSGROUP:IsIncludeObject(MGroup) - + function SET_OPSGROUP:IsIncludeObject( MGroup ) + -- Assume it is and check later if not. - local MGroupInclude=true + local MGroupInclude = true -- Filter active. - if self.Filter.Active~=nil then - + if self.Filter.Active ~= nil then + local MGroupActive = false - - if self.Filter.Active==false or (self.Filter.Active==true and MGroup:IsActive()==true) then + + if self.Filter.Active == false or (self.Filter.Active == true and MGroup:IsActive() == true) then MGroupActive = true end - + MGroupInclude = MGroupInclude and MGroupActive end -- Filter coalitions. if self.Filter.Coalitions then - + local MGroupCoalition = false - + for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do - if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName]==MGroup:GetCoalition() then - MGroupCoalition = true + if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName] == MGroup:GetCoalition() then + MGroupCoalition = true end end - + MGroupInclude = MGroupInclude and MGroupCoalition end -- Filter categories. if self.Filter.Categories then - + local MGroupCategory = false - + for CategoryID, CategoryName in pairs( self.Filter.Categories ) do - if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName]==MGroup:GetCategory() then + if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName] == MGroup:GetCategory() then MGroupCategory = true end end - + MGroupInclude = MGroupInclude and MGroupCategory end @@ -6772,19 +6596,19 @@ do -- SET_OPSGROUP -- Filter "prefixes". if self.Filter.GroupPrefixes then - + local MGroupPrefix = false - + for GroupPrefixId, GroupPrefix in pairs( self.Filter.GroupPrefixes ) do - if string.find( MGroup:GetName(), GroupPrefix:gsub ("-", "%%-"), 1 ) then --Not sure why "-" is replaced by "%-" ?! + if string.find( MGroup:GetName(), GroupPrefix:gsub( "-", "%%-" ), 1 ) then -- Not sure why "-" is replaced by "%-" ?! MGroupPrefix = true end end - + MGroupInclude = MGroupInclude and MGroupPrefix end return MGroupInclude end - + end diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index b2706fa02..dc5955d3d 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -334,11 +334,13 @@ function POSITIONABLE:GetPointVec3() return nil end ---- Returns a COORDINATE object indicating the point in 3D of the POSITIONABLE within the mission. --- If the POSITIONABLE has a COORDINATE OBJECT set, it updates it. If not, it creates a new COORDINATE object. +--- Returns a reference to a COORDINATE object indicating the point in 3D of the POSITIONABLE within the mission. +-- This function works similar to POSITIONABLE.GetCoordinate(), however, this function caches, updates and re-uses the same COORDINATE object stored +-- within the POSITIONABLE. This has higher performance, but comes with all considerations associated with the possible referencing to the same COORDINATE object. +-- This should only be used when performance is critical and there is sufficient awareness of the possible pitfalls. However, in most instances, GetCoordinate() is +-- preferred as it will return a fresh new COORDINATE and thus avoid potentially unexpected issues. -- @param Wrapper.Positionable#POSITIONABLE self --- @return Core.Point#COORDINATE The COORDINATE of the POSITIONABLE. --- TODO: Seems to have been introduced with Airboss. Should it be renamed to better reflect the difference to "GetCoordinate" (it is currently ambiguous)? Or perhaps just be a switch in the the GetCoordinate function; forceCoordinateUpate? +-- @return Core.Point#COORDINATE A reference to the COORDINATE object of the POSITIONABLE. function POSITIONABLE:GetCoord() -- Get DCS object. @@ -366,9 +368,9 @@ function POSITIONABLE:GetCoord() return nil end ---- Returns a COORDINATE object indicating the point in 3D of the POSITIONABLE within the mission. +--- Returns a new COORDINATE object indicating the point in 3D of the POSITIONABLE within the mission. -- @param Wrapper.Positionable#POSITIONABLE self --- @return Core.Point#COORDINATE The COORDINATE of the POSITIONABLE. +-- @return Core.Point#COORDINATE A new COORDINATE object of the POSITIONABLE. function POSITIONABLE:GetCoordinate() -- Get DCS object. @@ -512,15 +514,15 @@ end --- Get the bounding radius of the underlying POSITIONABLE DCS Object. -- @param #POSITIONABLE self --- @param #number mindist (Optional) If bounding box is smaller than this value, mindist is returned. +-- @param #number MinDist (Optional) If bounding box is smaller than this value, MinDist is returned. -- @return DCS#Distance The bounding radius of the POSITIONABLE -- @return #nil The POSITIONABLE is not existing or alive. -function POSITIONABLE:GetBoundingRadius( mindist ) +function POSITIONABLE:GetBoundingRadius( MinDist ) self:F2() local Box = self:GetBoundingBox() - local boxmin = mindist or 0 + local boxmin = MinDist or 0 if Box then local X = Box.max.x - Box.min.x local Z = Box.max.z - Box.min.z @@ -763,13 +765,13 @@ end --- Get relative velocity with respect to another POSITIONABLE. -- @param #POSITIONABLE self --- @param #POSITIONABLE positionable Other POSITIONABLE. +-- @param #POSITIONABLE Positionable Other POSITIONABLE. -- @return #number Relative velocity in m/s. -function POSITIONABLE:GetRelativeVelocity( positionable ) +function POSITIONABLE:GetRelativeVelocity( Positionable ) self:F2( self.PositionableName ) local v1 = self:GetVelocityVec3() - local v2 = positionable:GetVelocityVec3() + local v2 = Positionable:GetVelocityVec3() local vtot = UTILS.VecAdd( v1, v2 ) @@ -1446,7 +1448,7 @@ do -- Cargo -- @return #number CargoBayFreeWeight function POSITIONABLE:GetCargoBayFreeWeight() - -- When there is no cargo bay weight limit set, then calculate this for this positionable! + -- When there is no cargo bay weight limit set, then calculate this for this POSITIONABLE! if not self.__.CargoBayWeightLimit then self:SetCargoBayWeightLimit() end @@ -1475,9 +1477,9 @@ do -- Cargo elseif self.__.CargoBayWeightLimit ~= nil then -- Value already set ==> Do nothing! else - -- If weightlimit is not provided, we will calculate it depending on the type of unit. + -- If WeightLimit is not provided, we will calculate it depending on the type of unit. - -- When an airplane or helicopter, we calculate the weightlimit based on the descriptor. + -- When an airplane or helicopter, we calculate the WeightLimit based on the descriptor. if self:IsAir() then local Desc = self:GetDesc() self:F( { Desc = Desc } )