diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 87fbc64fd..c0565afc9 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -395,8 +395,8 @@ do -- COORDINATE id = world.VolumeType.SPHERE, params = { point = self:GetVec3(), - radius = radius - } + radius = radius, + }, } -- Defaults diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 964eb5d25..88c1e8760 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -20,9 +20,9 @@ -- Various types of SET_ classes are available: -- -- * @{#SET_GROUP}: Defines a collection of @{Wrapper.Group}s filtered by filter criteria. --- * @{#SET_UNIT}: Defines a colleciton of @{Wrapper.Unit}s filtered by filter criteria. +-- * @{#SET_UNIT}: Defines a collection of @{Wrapper.Unit}s filtered by filter criteria. -- * @{#SET_STATIC}: Defines a collection of @{Wrapper.Static}s filtered by filter criteria. --- * @{#SET_CLIENT}: Defines a collection of @{Client}s filterd by filter criteria. +-- * @{#SET_CLIENT}: Defines a collection of @{Client}s filtered by filter criteria. -- * @{#SET_AIRBASE}: Defines a collection of @{Wrapper.Airbase}s filtered by filter criteria. -- * @{#SET_CARGO}: Defines a collection of @{Cargo.Cargo}s filtered by filter criteria. -- * @{#SET_ZONE}: Defines a collection of @{Core.Zone}s filtered by filter criteria. @@ -44,20 +44,18 @@ -- @module Core.Set -- @image Core_Sets.JPG - do -- SET_BASE --- @type SET_BASE -- @field #table Filter Table of filters. -- @field #table Set Table of objects. - -- @field #table Index Table of indicies. + -- @field #table Index Table of indices. -- @field #table List Unused table. -- @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 interator loop at defined **"intervals"** to the mail simulator loop. + -- 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. -- The default **"yield interval"** is after 10 objects processed. -- The default **"time interval"** is after 0.001 seconds. @@ -68,7 +66,7 @@ do -- SET_BASE -- -- ## Define the SET iterator **"yield interval"** and the **"time interval"** -- - -- Modify the iterator intervals with the @{Core.Set#SET_BASE.SetInteratorIntervals} method. + -- Modify the iterator intervals with the @{Core.Set#SET_BASE.SetIteratorIntervals} method. -- You can set the **"yield interval"**, and the **"time interval"**. (See above). -- -- @field #SET_BASE SET_BASE @@ -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,7 +222,6 @@ 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. @@ -266,21 +258,20 @@ do -- SET_BASE end - --- Get the *union* of two sets. -- @param #SET_BASE self -- @param Core.Set#SET_BASE SetB Set *B*. -- @return Core.Set#SET_BASE The union set, i.e. contains objects that are in set *A* **or** in set *B*. - function SET_BASE:GetSetUnion(SetB) + function SET_BASE:GetSetUnion( SetB ) - local union=SET_BASE:New() + local union = SET_BASE:New() - for _,ObjectA in pairs(self.Set) do - union:AddObject(ObjectA) + for _, ObjectA in pairs( self.Set ) do + union:AddObject( ObjectA ) end - for _,ObjectB in pairs(SetB.Set) do - union:AddObject(ObjectB) + for _, ObjectB in pairs( SetB.Set ) do + union:AddObject( ObjectB ) end return union @@ -290,15 +281,15 @@ do -- SET_BASE -- @param #SET_BASE self -- @param Core.Set#SET_BASE SetB Set other set, called *B*. -- @return Core.Set#SET_BASE A set of objects that is included in set *A* **and** in set *B*. - function SET_BASE:GetSetIntersection(SetB) + function SET_BASE:GetSetIntersection( SetB ) - local intersection=SET_BASE:New() + local intersection = SET_BASE:New() - local union=self:GetSetUnion(SetB) + local union = self:GetSetUnion( SetB ) - for _,Object in pairs(union.Set) do - if self:IsIncludeObject(Object) and SetB:IsIncludeObject(Object) then - intersection:AddObject(intersection) + for _, Object in pairs( union.Set ) do + if self:IsIncludeObject( Object ) and SetB:IsIncludeObject( Object ) then + intersection:AddObject( intersection ) end end @@ -309,38 +300,34 @@ do -- SET_BASE -- @param #SET_BASE self -- @param Core.Set#SET_BASE SetB Set other set, called *B*. -- @return Core.Set#SET_BASE The set of objects that are in set *B* but **not** in this set *A*. - function SET_BASE:GetSetComplement(SetB) + function SET_BASE:GetSetComplement( SetB ) - local complement = self:GetSetUnion(SetB) - local intersection = self:GetSetIntersection(SetB) + local complement = self:GetSetUnion( SetB ) + local intersection = self:GetSetIntersection( SetB ) - for _,Object in pairs(intersection.Set) do - complement:Remove(Object.ObjectName,true) + for _, Object in pairs( intersection.Set ) do + complement:Remove( Object.ObjectName, true ) end return complement end - --- Compare two sets. -- @param #SET_BASE self -- @param Core.Set#SET_BASE SetA First set. -- @param Core.Set#SET_BASE SetB Set to be merged into first set. -- @return Core.Set#SET_BASE The set of objects that are included in SetA and SetB. - function SET_BASE:CompareSets(SetA, SetB) + function SET_BASE:CompareSets( SetA, SetB ) - for _,ObjectB in pairs(SetB.Set) do - if SetA:IsIncludeObject(ObjectB) then - SetA:Add(ObjectB) + for _, ObjectB in pairs( SetB.Set ) do + if SetA:IsIncludeObject( ObjectB ) then + SetA:Add( ObjectB ) end end return SetA end - - - --- Gets 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 @@ -381,12 +368,11 @@ do -- SET_BASE -- @return Core.Base#BASE function SET_BASE:GetRandom() - local RandomItem = self.Set[self.Index[math.random(#self.Index)]] + local RandomItem = self.Set[self.Index[math.random( #self.Index )]] self:T3( { RandomItem } ) return RandomItem end - --- Retrieves the amount of objects in the @{Core.Set#SET_BASE} and derived classes. -- @param #SET_BASE self -- @return #number Count @@ -395,7 +381,6 @@ do -- SET_BASE return self.Index and #self.Index or 0 end - --- Copies the Filter criteria from a given Set (for rebuilding a new Set based on an existing Set). -- @param #SET_BASE self -- @param #SET_BASE BaseSet @@ -411,8 +396,6 @@ do -- SET_BASE return self end - - --- Define the SET iterator **"yield interval"** and the **"time interval"**. -- @param #SET_BASE self -- @param #number YieldInterval Sets the frequency when the iterator loop will yield after the number of objects processed. The default frequency is 10 objects processed. @@ -437,7 +420,7 @@ do -- SET_BASE return self end - --- Get the SET iterator **"limit"**. + --- Get the SET iterator **"limit"**. -- @param #SET_BASE self -- @return #number Defines how many objects are evaluated of the set as part of the Some iterators. function SET_BASE:GetSomeIteratorLimit() @@ -445,7 +428,6 @@ do -- SET_BASE return self.SomeIteratorLimit or self:Count() end - --- Filters for the defined collection. -- @param #SET_BASE self -- @return #SET_BASE self @@ -474,9 +456,8 @@ do -- SET_BASE end -- Follow alive players and clients - --self:HandleEvent( EVENTS.PlayerEnterUnit, self._EventOnPlayerEnterUnit ) - --self:HandleEvent( EVENTS.PlayerLeaveUnit, self._EventOnPlayerLeaveUnit ) - + -- self:HandleEvent( EVENTS.PlayerEnterUnit, self._EventOnPlayerEnterUnit ) + -- self:HandleEvent( EVENTS.PlayerLeaveUnit, self._EventOnPlayerLeaveUnit ) return self end @@ -484,7 +465,7 @@ do -- SET_BASE --- Starts the filtering of the Dead events for the collection. -- @param #SET_BASE self -- @return #SET_BASE self - function SET_BASE:FilterDeads() --R2.1 allow deads to be filtered to automatically handle deads in the collection. + function SET_BASE:FilterDeads() -- R2.1 allow deads to be filtered to automatically handle deads in the collection. self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash ) @@ -494,7 +475,7 @@ do -- SET_BASE --- Starts the filtering of the Crash events for the collection. -- @param #SET_BASE self -- @return #SET_BASE self - function SET_BASE:FilterCrashes() --R2.1 allow crashes to be filtered to automatically handle crashes in the collection. + function SET_BASE:FilterCrashes() -- R2.1 allow crashes to be filtered to automatically handle crashes in the collection. self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash ) @@ -539,12 +520,10 @@ do -- SET_BASE return NearestObject end - - ----- Private method that registers all alive players in the mission. ---- @param #SET_BASE self ---- @return #SET_BASE self - --function SET_BASE:_RegisterPlayers() + -- function SET_BASE:_RegisterPlayers() -- -- local CoalitionsData = { AlivePlayersRed = coalition.getPlayers( coalition.side.RED ), AlivePlayersBlue = coalition.getPlayers( coalition.side.BLUE ) } -- for CoalitionId, CoalitionData in pairs( CoalitionsData ) do @@ -561,7 +540,7 @@ do -- SET_BASE -- end -- -- return self - --end + -- end --- Events @@ -576,7 +555,7 @@ do -- SET_BASE self:T3( ObjectName, Object ) if Object and self:IsIncludeObject( Object ) then self:Add( ObjectName, Object ) - --self:_EventOnPlayerEnterUnit( Event ) + -- self:_EventOnPlayerEnterUnit( Event ) end end end @@ -598,7 +577,7 @@ do -- SET_BASE --- Handles the OnPlayerEnterUnit event to fill the active players table (with the unit filter applied). -- @param #SET_BASE self -- @param Core.Event#EVENTDATA Event - --function SET_BASE:_EventOnPlayerEnterUnit( Event ) + -- function SET_BASE:_EventOnPlayerEnterUnit( Event ) -- self:F3( { Event } ) -- -- if Event.IniDCSUnit then @@ -609,12 +588,12 @@ do -- SET_BASE -- --self:_EventOnPlayerEnterUnit( Event ) -- end -- end - --end + -- end --- Handles the OnPlayerLeaveUnit event to clean the active players table. -- @param #SET_BASE self -- @param Core.Event#EVENTDATA Event - --function SET_BASE:_EventOnPlayerLeaveUnit( Event ) + -- function SET_BASE:_EventOnPlayerLeaveUnit( Event ) -- self:F3( { Event } ) -- -- local ObjectName = Event.IniDCSUnit @@ -635,7 +614,7 @@ do -- SET_BASE -- end -- end -- end - --end + -- end -- Iterators @@ -657,28 +636,28 @@ do -- SET_BASE local Count = 0 for ObjectID, ObjectData in pairs( Set ) do local Object = ObjectData - self:T3( Object ) - if Function then - if Function( unpack( FunctionArguments or {} ), Object ) == true then - IteratorFunction( Object, unpack( arg ) ) - end - else + self:T3( Object ) + if Function then + if Function( unpack( FunctionArguments or {} ), Object ) == true then IteratorFunction( Object, unpack( arg ) ) end - Count = Count + 1 - -- if Count % self.YieldInterval == 0 then - -- coroutine.yield( false ) - -- end + else + IteratorFunction( Object, unpack( arg ) ) + end + Count = Count + 1 + -- 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 } ) @@ -692,7 +671,7 @@ 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 @@ -714,31 +693,31 @@ do -- SET_BASE local Count = 0 for ObjectID, ObjectData in pairs( Set ) do local Object = ObjectData - self:T3( Object ) - if Function then - if Function( unpack( FunctionArguments ), Object ) == true then - IteratorFunction( Object, unpack( arg ) ) - end - else + self:T3( Object ) + if Function then + if Function( unpack( FunctionArguments ), Object ) == true then IteratorFunction( Object, unpack( arg ) ) end - Count = Count + 1 - if Count >= 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 } ) @@ -752,50 +731,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 interator function for each **alive** unit, providing the Unit and optional parameters. + ----- 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 interator function for each **alive** player, providing the Unit of the player and optional parameters. + ----- 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 interator function for each client, providing the Client to the function and optional parameters. + ----- 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 @@ -811,7 +788,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 @@ -833,7 +810,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() @@ -849,7 +826,6 @@ do -- SET_BASE end - do -- SET_GROUP --- @type SET_GROUP @@ -921,7 +897,7 @@ do -- SET_GROUP -- ### When a GROUP object crashes or is dead, the SET_GROUP will trigger a **Dead** event. -- -- You can handle the event using the OnBefore and OnAfter event handlers. - -- The event handlers need to have the paramters From, Event, To, GroupObject. + -- The event handlers need to have the parameters From, Event, To, GroupObject. -- The GroupObject is the GROUP object that is dead and within the SET_GROUP, and is passed as a parameter to the event handler. -- See the following example: -- @@ -936,7 +912,7 @@ do -- SET_GROUP -- end -- -- While this is a good example, there is a catch. - -- Imageine you want to execute the code above, the the self would need to be from the object declared outside (above) the OnAfterDead method. + -- Imagine you want to execute the code above, the the self would need to be from the object declared outside (above) the OnAfterDead method. -- So, the self would need to contain another object. Fortunately, this can be done, but you must use then the **`.`** notation for the method. -- See the modified example: -- @@ -985,7 +961,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 @@ -1012,7 +987,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 ) @@ -1079,7 +1054,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 ) ) @@ -1094,7 +1069,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 ) @@ -1103,9 +1078,6 @@ do -- SET_GROUP return self end - - - --- Finds a Group based on the Group Name. -- @param #SET_GROUP self -- @param #string GroupName @@ -1123,7 +1095,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 @@ -1142,7 +1114,6 @@ do -- SET_GROUP return NearestGroup end - --- Builds a set of groups of coalitions. -- Possible current coalitions are red, blue and neutral. -- @param #SET_GROUP self @@ -1161,7 +1132,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 @@ -1220,8 +1190,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 @@ -1240,7 +1208,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 @@ -1262,7 +1229,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 @@ -1280,12 +1247,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 @@ -1299,8 +1265,6 @@ do -- SET_GROUP self:HandleEvent( EVENTS.RemoveUnit, self._EventOnDeadOrCrash ) end - - return self end @@ -1408,16 +1372,15 @@ do -- SET_GROUP function SET_GROUP:ForEachGroupCompletelyInZone( ZoneObject, IteratorFunction, ... ) self:F2( arg ) - self:ForEach( IteratorFunction, arg, self:GetSet(), - --- @param Core.Zone#ZONE_BASE ZoneObject - -- @param Wrapper.Group#GROUP GroupObject - function( ZoneObject, GroupObject ) - if GroupObject:IsCompletelyInZone( ZoneObject ) then - return true - else - return false - end - end, { ZoneObject } ) + self:ForEach( IteratorFunction, arg, self:GetSet(), --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Group#GROUP GroupObject + function( ZoneObject, GroupObject ) + if GroupObject:IsCompletelyInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) return self end @@ -1430,16 +1393,15 @@ do -- SET_GROUP function SET_GROUP:ForEachGroupPartlyInZone( ZoneObject, IteratorFunction, ... ) self:F2( arg ) - self:ForEach( IteratorFunction, arg, self:GetSet(), - --- @param Core.Zone#ZONE_BASE ZoneObject - -- @param Wrapper.Group#GROUP GroupObject - function( ZoneObject, GroupObject ) - if GroupObject:IsPartlyInZone( ZoneObject ) then - return true - else - return false - end - end, { ZoneObject } ) + self:ForEach( IteratorFunction, arg, self:GetSet(), --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Group#GROUP GroupObject + function( ZoneObject, GroupObject ) + if GroupObject:IsPartlyInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) return self end @@ -1452,16 +1414,15 @@ do -- SET_GROUP function SET_GROUP:ForEachGroupNotInZone( ZoneObject, IteratorFunction, ... ) self:F2( arg ) - self:ForEach( IteratorFunction, arg, self:GetSet(), - --- @param Core.Zone#ZONE_BASE ZoneObject - -- @param Wrapper.Group#GROUP GroupObject - function( ZoneObject, GroupObject ) - if GroupObject:IsNotInZone( ZoneObject ) then - return true - else - return false - end - end, { ZoneObject } ) + self:ForEach( IteratorFunction, arg, self:GetSet(), --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Group#GROUP GroupObject + function( ZoneObject, GroupObject ) + if GroupObject:IsNotInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) return self end @@ -1469,7 +1430,7 @@ do -- SET_GROUP --- Iterate the SET_GROUP and return true if all the @{Wrapper.Group#GROUP} are completely in the @{Core.Zone#ZONE} -- @param #SET_GROUP self -- @param Core.Zone#ZONE ZoneObject The Zone to be tested for. - -- @return #boolean true if all the @{Wrapper.Group#GROUP} are completly in the @{Core.Zone#ZONE}, false otherwise + -- @return #boolean true if all the @{Wrapper.Group#GROUP} are completely in the @{Core.Zone#ZONE}, false otherwise -- @usage -- local MyZone = ZONE:New("Zone1") -- local MySetGroup = SET_GROUP:New() @@ -1480,11 +1441,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 @@ -1499,25 +1460,23 @@ do -- SET_GROUP function SET_GROUP:ForEachGroupAnyInZone( ZoneObject, IteratorFunction, ... ) self:F2( arg ) - self:ForEach( IteratorFunction, arg, self:GetSet(), - --- @param Core.Zone#ZONE_BASE ZoneObject - -- @param Wrapper.Group#GROUP GroupObject - function( ZoneObject, GroupObject ) - if GroupObject:IsAnyInZone( ZoneObject ) then - return true - else - return false - end - end, { ZoneObject } ) + self:ForEach( IteratorFunction, arg, self:GetSet(), --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Group#GROUP GroupObject + function( ZoneObject, GroupObject ) + if GroupObject:IsAnyInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) 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. - -- @return #boolean true if at least one of the @{Wrapper.Group#GROUP} is completly inside the @{Core.Zone#ZONE}, false otherwise. + -- @return #boolean true if at least one of the @{Wrapper.Group#GROUP} is completely inside the @{Core.Zone#ZONE}, false otherwise. -- @usage -- local MyZone = ZONE:New("Zone1") -- local MySetGroup = SET_GROUP:New() @@ -1528,11 +1487,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 @@ -1542,7 +1501,7 @@ do -- SET_GROUP --- Iterate the SET_GROUP and return true if at least one @{#UNIT} of one @{GROUP} of the @{SET_GROUP} is in @{ZONE} -- @param #SET_GROUP self -- @param Core.Zone#ZONE ZoneObject The Zone to be tested for. - -- @return #boolean true if at least one of the @{Wrapper.Group#GROUP} is partly or completly inside the @{Core.Zone#ZONE}, false otherwise. + -- @return #boolean true if at least one of the @{Wrapper.Group#GROUP} is partly or completely inside the @{Core.Zone#ZONE}, false otherwise. -- @usage -- local MyZone = ZONE:New("Zone1") -- local MySetGroup = SET_GROUP:New() @@ -1553,11 +1512,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 @@ -1568,7 +1527,7 @@ do -- SET_GROUP -- Will return false if a @{GROUP} is fully in the @{ZONE} -- @param #SET_GROUP self -- @param Core.Zone#ZONE ZoneObject The Zone to be tested for. - -- @return #boolean true if at least one of the @{Wrapper.Group#GROUP} is partly or completly inside the @{Core.Zone#ZONE}, false otherwise. + -- @return #boolean true if at least one of the @{Wrapper.Group#GROUP} is partly or completely inside the @{Core.Zone#ZONE}, false otherwise. -- @usage -- local MyZone = ZONE:New("Zone1") -- local MySetGroup = SET_GROUP:New() @@ -1579,14 +1538,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 @@ -1614,11 +1573,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 @@ -1637,12 +1596,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 @@ -1659,12 +1618,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 @@ -1679,50 +1638,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 interator function for each **alive** player, providing the Group of the player and optional parameters. + ----- 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 interator function for each client, providing the Client to the function and optional parameters. + ----- 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 @@ -1735,7 +1693,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 @@ -1778,7 +1736,7 @@ 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 @@ -1789,7 +1747,6 @@ do -- SET_GROUP 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 @@ -1801,7 +1758,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 @@ -1809,7 +1766,6 @@ do -- SET_GROUP end - do -- SET_UNIT --- @type SET_UNIT @@ -1884,7 +1840,7 @@ do -- SET_UNIT -- ### 6.1) When a UNIT object crashes or is dead, the SET_UNIT will trigger a **Dead** event. -- -- You can handle the event using the OnBefore and OnAfter event handlers. - -- The event handlers need to have the paramters From, Event, To, GroupObject. + -- The event handlers need to have the parameters From, Event, To, GroupObject. -- The GroupObject is the UNIT object that is dead and within the SET_UNIT, and is passed as a parameter to the event handler. -- See the following example: -- @@ -1899,7 +1855,7 @@ do -- SET_UNIT -- end -- -- While this is a good example, there is a catch. - -- Imageine you want to execute the code above, the the self would need to be from the object declared outside (above) the OnAfterDead method. + -- Imagine you want to execute the code above, the the self would need to be from the object declared outside (above) the OnAfterDead method. -- So, the self would need to contain another object. Fortunately, this can be done, but you must use then the **`.`** notation for the method. -- See the modified example: -- @@ -1948,7 +1904,6 @@ do -- SET_UNIT }, } - --- Get the first unit from the set. -- @function [parent=#SET_UNIT] GetFirst -- @param #SET_UNIT self @@ -1985,14 +1940,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 @@ -2008,7 +1962,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 ) @@ -2017,7 +1971,6 @@ do -- SET_UNIT return self end - --- Finds a Unit based on the Unit Name. -- @param #SET_UNIT self -- @param #string UnitName @@ -2028,8 +1981,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 @@ -2047,7 +1998,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 @@ -2066,7 +2016,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 @@ -2085,7 +2034,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 @@ -2104,7 +2052,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 @@ -2126,7 +2073,7 @@ do -- SET_UNIT --- 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 @@ -2144,7 +2091,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 @@ -2183,7 +2130,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 @@ -2209,8 +2156,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 @@ -2239,11 +2184,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. @@ -2256,7 +2199,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 @@ -2272,7 +2215,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. @@ -2283,7 +2225,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 @@ -2299,8 +2241,7 @@ do -- SET_UNIT end - - --- Iterate the SET_UNIT and call an interator function for each **alive** UNIT, providing the UNIT and optional parameters. + --- 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. -- @return #SET_UNIT self @@ -2312,16 +2253,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 ) @@ -2338,12 +2275,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] @@ -2359,8 +2294,7 @@ do -- SET_UNIT end - - --- Iterate the SET_UNIT **sorted *per Threat Level** and call an interator function for each **alive** UNIT, providing the UNIT and optional parameters. + --- 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 -- @param #number FromThreatLevel The TreatLevel to start the evaluation **From** (this must be a value between 0 and 10). @@ -2376,7 +2310,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 = {} @@ -2406,8 +2340,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. @@ -2416,16 +2348,15 @@ do -- SET_UNIT function SET_UNIT:ForEachUnitCompletelyInZone( ZoneObject, IteratorFunction, ... ) self:F2( arg ) - self:ForEach( IteratorFunction, arg, self:GetSet(), - --- @param Core.Zone#ZONE_BASE ZoneObject - -- @param Wrapper.Unit#UNIT UnitObject - function( ZoneObject, UnitObject ) - if UnitObject:IsInZone( ZoneObject ) then - return true - else - return false - end - end, { ZoneObject } ) + self:ForEach( IteratorFunction, arg, self:GetSet(), --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Unit#UNIT UnitObject + function( ZoneObject, UnitObject ) + if UnitObject:IsInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) return self end @@ -2438,16 +2369,15 @@ do -- SET_UNIT function SET_UNIT:ForEachUnitNotInZone( ZoneObject, IteratorFunction, ... ) self:F2( arg ) - self:ForEach( IteratorFunction, arg, self:GetSet(), - --- @param Core.Zone#ZONE_BASE ZoneObject - -- @param Wrapper.Unit#UNIT UnitObject - function( ZoneObject, UnitObject ) - if UnitObject:IsNotInZone( ZoneObject ) then - return true - else - return false - end - end, { ZoneObject } ) + self:ForEach( IteratorFunction, arg, self:GetSet(), --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Unit#UNIT UnitObject + function( ZoneObject, UnitObject ) + if UnitObject:IsNotInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) return self end @@ -2475,13 +2405,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 @@ -2492,7 +2421,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, ", " ) @@ -2522,7 +2451,7 @@ do -- SET_UNIT return UnitThreatLevels end - --- Calculate the maxium A2G threat level of the SET_UNIT. + --- Calculate the maximum A2G threat level of the SET_UNIT. -- @param #SET_UNIT self -- @return #number The maximum threatlevel function SET_UNIT:CalculateThreatLevelA2G() @@ -2565,27 +2494,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 ) @@ -2609,8 +2538,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 @@ -2633,12 +2562,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 @@ -2652,8 +2581,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 @@ -2662,7 +2589,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 @@ -2670,7 +2597,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 @@ -2686,14 +2613,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 @@ -2710,7 +2637,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 @@ -2744,7 +2671,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 @@ -2754,33 +2681,30 @@ do -- SET_UNIT return FriendlyUnitCount end - - - ----- Iterate the SET_UNIT and call an interator function for each **alive** player, providing the Unit of the player and optional parameters. + ----- 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 interator function for each client, providing the Client to the function and optional parameters. + ----- 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 @@ -2797,7 +2721,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 @@ -2886,10 +2810,9 @@ do -- SET_UNIT 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 ) @@ -2920,16 +2843,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 @@ -3023,7 +2943,6 @@ do -- SET_STATIC }, } - --- Get the first unit from the set. -- @function [parent=#SET_STATIC] GetFirst -- @param #SET_STATIC self @@ -3055,14 +2974,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 @@ -3078,7 +2996,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 ) @@ -3087,7 +3005,6 @@ do -- SET_STATIC return self end - --- Finds a Static based on the Static Name. -- @param #SET_STATIC self -- @param #string StaticName @@ -3098,8 +3015,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 @@ -3118,7 +3033,6 @@ do -- SET_STATIC return self end - --- Builds a set of units out of categories. -- Possible current categories are plane, helicopter, ground, ship. -- @param #SET_STATIC self @@ -3137,7 +3051,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 @@ -3156,7 +3069,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 @@ -3175,7 +3087,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 @@ -3194,7 +3105,6 @@ do -- SET_STATIC return self end - --- Starts the filtering. -- @param #SET_STATIC self -- @return #SET_STATIC self @@ -3218,7 +3128,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 @@ -3256,11 +3166,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. @@ -3273,7 +3181,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 @@ -3285,7 +3193,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. @@ -3296,7 +3203,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 @@ -3310,7 +3217,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. @@ -3323,11 +3229,9 @@ do -- SET_STATIC return self end - end - - --- Iterate the SET_STATIC and call an interator function for each **alive** STATIC, providing the STATIC and optional parameters. + --- 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. -- @return #SET_STATIC self @@ -3339,7 +3243,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. @@ -3348,16 +3251,15 @@ do -- SET_STATIC function SET_STATIC:ForEachStaticCompletelyInZone( ZoneObject, IteratorFunction, ... ) self:F2( arg ) - self:ForEach( IteratorFunction, arg, self:GetSet(), - --- @param Core.Zone#ZONE_BASE ZoneObject - -- @param Wrapper.Static#STATIC StaticObject - function( ZoneObject, StaticObject ) - if StaticObject:IsInZone( ZoneObject ) then - return true - else - return false - end - end, { ZoneObject } ) + self:ForEach( IteratorFunction, arg, self:GetSet(), --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Static#STATIC StaticObject + function( ZoneObject, StaticObject ) + if StaticObject:IsInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) return self end @@ -3370,16 +3272,15 @@ do -- SET_STATIC function SET_STATIC:ForEachStaticNotInZone( ZoneObject, IteratorFunction, ... ) self:F2( arg ) - self:ForEach( IteratorFunction, arg, self:GetSet(), - --- @param Core.Zone#ZONE_BASE ZoneObject - -- @param Wrapper.Static#STATIC StaticObject - function( ZoneObject, StaticObject ) - if StaticObject:IsNotInZone( ZoneObject ) then - return true - else - return false - end - end, { ZoneObject } ) + self:ForEach( IteratorFunction, arg, self:GetSet(), --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Static#STATIC StaticObject + function( ZoneObject, StaticObject ) + if StaticObject:IsNotInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) return self end @@ -3407,13 +3308,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 @@ -3424,7 +3324,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, ", " ) @@ -3452,27 +3352,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 ) @@ -3504,12 +3404,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 @@ -3528,19 +3428,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 @@ -3611,10 +3511,9 @@ do -- SET_STATIC 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 ) @@ -3638,15 +3537,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 @@ -3745,7 +3640,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 ) ) @@ -3760,7 +3655,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 ) @@ -3769,7 +3664,6 @@ do -- SET_CLIENT return self end - --- Finds a Client based on the Client Name. -- @param #SET_CLIENT self -- @param #string ClientName @@ -3780,8 +3674,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 @@ -3800,7 +3692,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 @@ -3819,7 +3710,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 @@ -3838,7 +3728,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 @@ -3857,7 +3746,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 @@ -3879,7 +3767,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 @@ -3897,13 +3785,11 @@ 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 - - --- Starts the filtering. -- @param #SET_CLIENT self -- @return #SET_CLIENT self @@ -3943,7 +3829,7 @@ do -- SET_CLIENT return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] end - --- Iterate the SET_CLIENT and call an interator function for each **alive** CLIENT, providing the CLIENT and optional parameters. + --- Iterate the SET_CLIENT and call an iterator function for each **alive** CLIENT, providing the CLIENT and optional parameters. -- @param #SET_CLIENT self -- @param #function IteratorFunction The function that will be called when there is an alive CLIENT in the SET_CLIENT. The function needs to accept a CLIENT parameter. -- @return #SET_CLIENT self @@ -3963,16 +3849,15 @@ do -- SET_CLIENT function SET_CLIENT:ForEachClientInZone( ZoneObject, IteratorFunction, ... ) self:F2( arg ) - self:ForEach( IteratorFunction, arg, self:GetSet(), - --- @param Core.Zone#ZONE_BASE ZoneObject - -- @param Wrapper.Client#CLIENT ClientObject - function( ZoneObject, ClientObject ) - if ClientObject:IsInZone( ZoneObject ) then - return true - else - return false - end - end, { ZoneObject } ) + self:ForEach( IteratorFunction, arg, self:GetSet(), --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Client#CLIENT ClientObject + function( ZoneObject, ClientObject ) + if ClientObject:IsInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) return self end @@ -3985,20 +3870,19 @@ do -- SET_CLIENT function SET_CLIENT:ForEachClientNotInZone( ZoneObject, IteratorFunction, ... ) self:F2( arg ) - self:ForEach( IteratorFunction, arg, self:GetSet(), - --- @param Core.Zone#ZONE_BASE ZoneObject - -- @param Wrapper.Client#CLIENT ClientObject - function( ZoneObject, ClientObject ) - if ClientObject:IsNotInZone( ZoneObject ) then - return true - else - return false - end - end, { ZoneObject } ) + self:ForEach( IteratorFunction, arg, self:GetSet(), --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Client#CLIENT ClientObject + function( ZoneObject, ClientObject ) + if ClientObject:IsNotInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) return self end - + --- Iterate the SET_CLIENT and count alive units. -- @param #SET_CLIENT self -- @return #number count @@ -4007,7 +3891,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 @@ -4016,7 +3900,7 @@ do -- SET_CLIENT return CountU end - + --- -- @param #SET_CLIENT self -- @param Wrapper.Client#CLIENT MClient @@ -4031,7 +3915,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 @@ -4078,7 +3962,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 @@ -4107,14 +3991,11 @@ do -- SET_CLIENT 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 @@ -4178,7 +4059,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 @@ -4198,7 +4078,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 ) ) @@ -4213,7 +4093,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 ) @@ -4222,7 +4102,6 @@ do -- SET_PLAYER return self end - --- Finds a Client based on the Player Name. -- @param #SET_PLAYER self -- @param #string PlayerName @@ -4233,8 +4112,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 @@ -4253,7 +4130,6 @@ do -- SET_PLAYER return self end - --- Builds a set of clients out of categories joined by players. -- Possible current categories are plane, helicopter, ground, ship. -- @param #SET_PLAYER self @@ -4272,7 +4148,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 @@ -4291,7 +4166,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 @@ -4310,7 +4184,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 @@ -4329,9 +4202,6 @@ do -- SET_PLAYER return self end - - - --- Starts the filtering. -- @param #SET_PLAYER self -- @return #SET_PLAYER self @@ -4371,7 +4241,7 @@ do -- SET_PLAYER return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] end - --- Iterate the SET_PLAYER and call an interator function for each **alive** CLIENT, providing the CLIENT and optional parameters. + --- Iterate the SET_PLAYER and call an iterator function for each **alive** CLIENT, providing the CLIENT and optional parameters. -- @param #SET_PLAYER self -- @param #function IteratorFunction The function that will be called when there is an alive CLIENT in the SET_PLAYER. The function needs to accept a CLIENT parameter. -- @return #SET_PLAYER self @@ -4391,16 +4261,15 @@ do -- SET_PLAYER function SET_PLAYER:ForEachPlayerInZone( ZoneObject, IteratorFunction, ... ) self:F2( arg ) - self:ForEach( IteratorFunction, arg, self:GetSet(), - --- @param Core.Zone#ZONE_BASE ZoneObject - -- @param Wrapper.Client#CLIENT ClientObject - function( ZoneObject, ClientObject ) - if ClientObject:IsInZone( ZoneObject ) then - return true - else - return false - end - end, { ZoneObject } ) + self:ForEach( IteratorFunction, arg, self:GetSet(), --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Client#CLIENT ClientObject + function( ZoneObject, ClientObject ) + if ClientObject:IsInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) return self end @@ -4413,16 +4282,15 @@ do -- SET_PLAYER function SET_PLAYER:ForEachPlayerNotInZone( ZoneObject, IteratorFunction, ... ) self:F2( arg ) - self:ForEach( IteratorFunction, arg, self:GetSet(), - --- @param Core.Zone#ZONE_BASE ZoneObject - -- @param Wrapper.Client#CLIENT ClientObject - function( ZoneObject, ClientObject ) - if ClientObject:IsNotInZone( ZoneObject ) then - return true - else - return false - end - end, { ZoneObject } ) + self:ForEach( IteratorFunction, arg, self:GetSet(), --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Client#CLIENT ClientObject + function( ZoneObject, ClientObject ) + if ClientObject:IsNotInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) return self end @@ -4480,7 +4348,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 @@ -4509,7 +4377,6 @@ do -- SET_PLAYER end - do -- SET_AIRBASE --- @type SET_AIRBASE @@ -4571,7 +4438,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 @@ -4602,7 +4468,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 ) ) @@ -4617,7 +4483,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 ) @@ -4626,7 +4492,6 @@ do -- SET_AIRBASE return self end - --- Finds a Airbase based on the Airbase Name. -- @param #SET_AIRBASE self -- @param #string AirbaseName @@ -4637,7 +4502,6 @@ do -- SET_AIRBASE return AirbaseFound end - --- Finds an Airbase in range of a coordinate. -- @param #SET_AIRBASE self -- @param Core.Point#COORDINATE Coordinate @@ -4652,7 +4516,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 @@ -4664,7 +4528,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. @@ -4676,8 +4539,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 @@ -4696,7 +4557,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 @@ -4723,8 +4583,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 @@ -4742,7 +4602,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 @@ -4760,17 +4620,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 @@ -4793,7 +4652,7 @@ do -- SET_AIRBASE return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] end - --- Iterate the SET_AIRBASE and call an interator function for each AIRBASE, providing the AIRBASE and optional parameters. + --- Iterate the SET_AIRBASE and call an iterator function for each AIRBASE, providing the AIRBASE and optional parameters. -- @param #SET_AIRBASE self -- @param #function IteratorFunction The function that will be called when there is an alive AIRBASE in the SET_AIRBASE. The function needs to accept a AIRBASE parameter. -- @return #SET_AIRBASE self @@ -4816,8 +4675,6 @@ do -- SET_AIRBASE return NearestAirbase end - - --- -- @param #SET_AIRBASE self -- @param Wrapper.Airbase#AIRBASE MAirbase @@ -4863,7 +4720,6 @@ do -- SET_AIRBASE end - do -- SET_CARGO --- @type SET_CARGO @@ -4928,40 +4784,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 ) ) @@ -4974,9 +4827,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 ) @@ -4985,25 +4838,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 @@ -5021,7 +4871,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 @@ -5034,13 +4884,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 @@ -5053,13 +4902,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 @@ -5072,12 +4920,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() @@ -5099,14 +4945,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] @@ -5118,17 +4963,17 @@ 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] end - --- (R2.1) Iterate the SET_CARGO and call an interator function for each CARGO, providing the CARGO and optional parameters. + --- (R2.1) Iterate the SET_CARGO and call an iterator function for each CARGO, providing the CARGO and optional parameters. -- @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() ) @@ -5140,7 +4985,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 ) @@ -5175,7 +5020,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}. @@ -5184,7 +5028,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}. @@ -5193,7 +5036,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}. @@ -5202,7 +5044,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}. @@ -5211,14 +5052,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 @@ -5271,13 +5109,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 @@ -5285,20 +5123,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 ) @@ -5309,7 +5147,6 @@ do -- SET_CARGO end - do -- SET_ZONE --- @type SET_ZONE @@ -5349,17 +5186,15 @@ do -- SET_ZONE -- -- === -- @field #SET_ZONE SET_ZONE - SET_ZONE = { - ClassName = "SET_ZONE", + SET_ZONE = { + lassName = "SET_ZONE", Zones = {}, Filter = { Prefixes = nil, }, - FilterMeta = { - }, + FilterMeta = {}, } - --- Creates a new SET_ZONE object, building a set of zones. -- @param #SET_ZONE self -- @return #SET_ZONE self @@ -5379,7 +5214,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 ) ) @@ -5399,14 +5234,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 ) @@ -5415,7 +5249,6 @@ do -- SET_ZONE return self end - --- Finds a Zone based on the Zone Name. -- @param #SET_ZONE self -- @param #string ZoneName @@ -5426,14 +5259,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 @@ -5456,7 +5288,6 @@ do -- SET_ZONE return nil end - --- Set a zone probability. -- @param #SET_ZONE self -- @param #string ZoneName The name of the zone. @@ -5465,9 +5296,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 @@ -5486,7 +5314,6 @@ do -- SET_ZONE return self end - --- Starts the filtering. -- @param #SET_ZONE self -- @return #SET_ZONE self @@ -5545,7 +5372,7 @@ do -- SET_ZONE return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] end - --- Iterate the SET_ZONE and call an interator function for each ZONE, providing the ZONE and optional parameters. + --- Iterate the SET_ZONE and call an iterator function for each ZONE, providing the ZONE and optional parameters. -- @param #SET_ZONE self -- @param #function IteratorFunction The function that will be called when there is an alive ZONE in the SET_ZONE. The function needs to accept a AIRBASE parameter. -- @return #SET_ZONE self @@ -5557,7 +5384,6 @@ do -- SET_ZONE return self end - --- -- @param #SET_ZONE self -- @param Core.Zone#ZONE_BASE MZone @@ -5590,13 +5416,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 @@ -5604,20 +5430,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 ) @@ -5692,11 +5518,9 @@ 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 @@ -5721,14 +5545,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 ) @@ -5737,7 +5560,6 @@ do -- SET_ZONE_GOAL return self end - --- Finds a Zone based on the Zone Name. -- @param #SET_ZONE_GOAL self -- @param #string ZoneName @@ -5748,7 +5570,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. @@ -5774,7 +5595,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. @@ -5783,9 +5603,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 @@ -5804,7 +5621,6 @@ do -- SET_ZONE_GOAL return self end - --- Starts the filtering. -- @param #SET_ZONE_GOAL self -- @return #SET_ZONE_GOAL self @@ -5863,7 +5679,7 @@ do -- SET_ZONE_GOAL return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] end - --- Iterate the SET_ZONE_GOAL and call an interator function for each ZONE, providing the ZONE and optional parameters. + --- Iterate the SET_ZONE_GOAL and call an iterator function for each ZONE, providing the ZONE and optional parameters. -- @param #SET_ZONE_GOAL self -- @param #function IteratorFunction The function that will be called when there is an alive ZONE in the SET_ZONE_GOAL. The function needs to accept a AIRBASE parameter. -- @return #SET_ZONE_GOAL self @@ -5875,7 +5691,6 @@ do -- SET_ZONE_GOAL return self end - --- -- @param #SET_ZONE_GOAL self -- @param Core.Zone#ZONE_BASE MZone @@ -5916,7 +5731,7 @@ do -- SET_ZONE_GOAL if EventData.ZoneGoal then if EventData.ZoneGoal and self:IsIncludeObject( EventData.ZoneGoal ) then self:I( { "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 @@ -5924,20 +5739,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 ) diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index a225ce5c5..535d7fd03 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -45,10 +45,10 @@ -- === -- -- ### Author: **funkyfranky** +-- -- @module Ops.Atis -- @image OPS_ATIS.png - --- ATIS class. -- @type ATIS -- @field #string ClassName Name of the class. @@ -126,7 +126,7 @@ -- ## Subtitles -- -- Currently, DCS allows for displaying subtitles of radio transmissions only from airborne units, *i.e.* airplanes and helicopters. Therefore, if you want to have subtitles, it is necessary to place an --- additonal aircraft on the ATIS airport and set it to uncontrolled. This unit can then function as a radio relay to transmit messages with subtitles. These subtitles will only be displayed, if the +-- additional aircraft on the ATIS airport and set it to uncontrolled. This unit can then function as a radio relay to transmit messages with subtitles. These subtitles will only be displayed, if the -- player has tuned in the correct ATIS frequency. -- -- Radio transmissions via an airborne unit can be set via the @{#ATIS.SetRadioRelayUnitName}(*unitname*) function, where the parameter *unitname* is the name of the unit passed as string, *e.g.* @@ -142,7 +142,7 @@ -- -- ## Active Runway -- --- By default, the currently active runway is determined automatically by analysing the wind direction. Therefore, you should obviously set the wind speed to be greater zero in your mission. +-- By default, the currently active runway is determined automatically by analyzing the wind direction. Therefore, you should obviously set the wind speed to be greater zero in your mission. -- -- Note however, there are a few special cases, where automatic detection does not yield the correct or desired result. -- For example, there are airports with more than one runway facing in the same direction (usually denoted left and right). In this case, there is obviously no *unique* result depending on the wind vector. @@ -170,7 +170,7 @@ -- -- ## Nav Aids -- --- Frequencies or channels of navigation aids can be specified by the user and are then provided as additional information. Unfortunately, it is **not possible** to aquire this information via the DCS API +-- Frequencies or channels of navigation aids can be specified by the user and are then provided as additional information. Unfortunately, it is **not possible** to acquire this information via the DCS API -- we have access to. -- -- As they say, all road lead to Rome but (for me) the easiest way to obtain the available nav aids data of an airport, is to start a mission and click on an airport symbol. @@ -256,14 +256,14 @@ -- # Marks on the F10 Map -- -- You can place marks on the F10 map via the @{#ATIS.SetMapMarks}() function. These will contain info about the ATIS frequency, the currently active runway and some basic info about the weather (wind, pressure and temperature). --- +-- -- # Text-To-Speech --- --- You can enable text-to-speech ATIS information with the @{#ATIS.SetSRS}() function. This uses [SRS](http://dcssimpleradio.com/) (Version >= 1.9.6.0) for broadcasing. +-- +-- You can enable text-to-speech ATIS information with the @{#ATIS.SetSRS}() function. This uses [SRS](http://dcssimpleradio.com/) (Version >= 1.9.6.0) for broadcasting. -- Advantages are that **no sound files** or radio relay units are necessary. Also the issue that FC3 aircraft hear all transmissions will be circumvented. --- +-- -- The @{#ATIS.SetSRS}() requires you to specify the path to the SRS install directory or more specifically the path to the DCS-SR-ExternalAudio.exe file. --- +-- -- Unfortunately, it is not possible to determine the duration of the complete transmission. So once the transmission is finished, there might be some radio silence before -- the next iteration begins. You can fine tune the time interval between transmissions with the @{#ATIS.SetQueueUpdateTime}() function. The default interval is 90 seconds. -- @@ -297,9 +297,9 @@ -- atisAbuDhabi:SetTowerFrequencies({250.5, 119.2}) -- atisAbuDhabi:SetVOR(114.25) -- atisAbuDhabi:Start() --- +-- -- ## SRS --- +-- -- atis=ATIS:New("Batumi", 305, radio.modulation.AM) -- atis:SetSRS("D:\\DCS\\_SRS\\", "male", "en-US") -- atis:Start() @@ -390,14 +390,14 @@ ATIS.Alphabet = { -- @field #number TheChannel -10° (West). -- @field #number Syria +5° (East). -- @field #number MarianaIslands +2° (East). -ATIS.RunwayM2T={ - Caucasus=0, - Nevada=12, - Normandy=-10, - PersianGulf=2, - TheChannel=-10, - Syria=5, - MarianaIslands=2, +ATIS.RunwayM2T = { + Caucasus = 0, + Nevada = 12, + Normandy = -10, + PersianGulf = 2, + TheChannel = -10, + Syria = 5, + MarianaIslands = 2, } --- Whether ICAO phraseology is used for ATIS broadcasts. @@ -409,14 +409,14 @@ ATIS.RunwayM2T={ -- @field #boolean TheChannel true. -- @field #boolean Syria true. -- @field #boolean MarianaIslands true. -ATIS.ICAOPhraseology={ - Caucasus=true, - Nevada=false, - Normandy=true, - PersianGulf=true, - TheChannel=true, - Syria=true, - MarianaIslands=true, +ATIS.ICAOPhraseology = { + Caucasus = true, + Nevada = false, + Normandy = true, + PersianGulf = true, + TheChannel = true, + Syria = true, + MarianaIslands = true } --- Nav point data. @@ -505,91 +505,90 @@ ATIS.ICAOPhraseology={ -- @field #ATIS.Soundfile TACANChannel -- @field #ATIS.Soundfile VORFrequency ATIS.Sound = { - ActiveRunway={filename="ActiveRunway.ogg", duration=0.99}, - AdviceOnInitial={filename="AdviceOnInitial.ogg", duration=3.00}, - Airport={filename="Airport.ogg", duration=0.66}, - Altimeter={filename="Altimeter.ogg", duration=0.68}, - At={filename="At.ogg", duration=0.41}, - CloudBase={filename="CloudBase.ogg", duration=0.82}, - CloudCeiling={filename="CloudCeiling.ogg", duration=0.61}, - CloudsBroken={filename="CloudsBroken.ogg", duration=1.07}, - CloudsFew={filename="CloudsFew.ogg", duration=0.99}, - CloudsNo={filename="CloudsNo.ogg", duration=1.01}, - CloudsNotAvailable={filename="CloudsNotAvailable.ogg", duration=2.35}, - CloudsOvercast={filename="CloudsOvercast.ogg", duration=0.83}, - CloudsScattered={filename="CloudsScattered.ogg", duration=1.18}, - Decimal={filename="Decimal.ogg", duration=0.54}, - DegreesCelsius={filename="DegreesCelsius.ogg", duration=1.27}, - DegreesFahrenheit={filename="DegreesFahrenheit.ogg", duration=1.23}, - DewPoint={filename="DewPoint.ogg", duration=0.65}, - Dust={filename="Dust.ogg", duration=0.54}, - Elevation={filename="Elevation.ogg", duration=0.78}, - EndOfInformation={filename="EndOfInformation.ogg", duration=1.15}, - Feet={filename="Feet.ogg", duration=0.45}, - Fog={filename="Fog.ogg", duration=0.47}, - Gusting={filename="Gusting.ogg", duration=0.55}, - HectoPascal={filename="HectoPascal.ogg", duration=1.15}, - Hundred={filename="Hundred.ogg", duration=0.47}, - InchesOfMercury={filename="InchesOfMercury.ogg", duration=1.16}, - Information={filename="Information.ogg", duration=0.85}, - Kilometers={filename="Kilometers.ogg", duration=0.78}, - Knots={filename="Knots.ogg", duration=0.59}, - Left={filename="Left.ogg", duration=0.54}, - MegaHertz={filename="MegaHertz.ogg", duration=0.87}, - Meters={filename="Meters.ogg", duration=0.59}, - MetersPerSecond={filename="MetersPerSecond.ogg", duration=1.14}, - Miles={filename="Miles.ogg", duration=0.60}, - MillimetersOfMercury={filename="MillimetersOfMercury.ogg", duration=1.53}, - Minus={filename="Minus.ogg", duration=0.64}, - N0={filename="N-0.ogg", duration=0.55}, - N1={filename="N-1.ogg", duration=0.41}, - N2={filename="N-2.ogg", duration=0.37}, - N3={filename="N-3.ogg", duration=0.41}, - N4={filename="N-4.ogg", duration=0.37}, - N5={filename="N-5.ogg", duration=0.43}, - N6={filename="N-6.ogg", duration=0.55}, - N7={filename="N-7.ogg", duration=0.43}, - N8={filename="N-8.ogg", duration=0.38}, - N9={filename="N-9.ogg", duration=0.55}, - NauticalMiles={filename="NauticalMiles.ogg", duration=1.04}, - None={filename="None.ogg", duration=0.43}, - QFE={filename="QFE.ogg", duration=0.63}, - QNH={filename="QNH.ogg", duration=0.71}, - Rain={filename="Rain.ogg", duration=0.41}, - Right={filename="Right.ogg", duration=0.44}, - Snow={filename="Snow.ogg", duration=0.48}, - SnowStorm={filename="SnowStorm.ogg", duration=0.82}, - StatuteMiles={filename="StatuteMiles.ogg", duration=1.15}, - SunriseAt={filename="SunriseAt.ogg", duration=0.92}, - SunsetAt={filename="SunsetAt.ogg", duration=0.95}, - Temperature={filename="Temperature.ogg", duration=0.64}, - Thousand={filename="Thousand.ogg", duration=0.55}, - ThunderStorm={filename="ThunderStorm.ogg", duration=0.81}, - TimeLocal={filename="TimeLocal.ogg", duration=0.90}, - TimeZulu={filename="TimeZulu.ogg", duration=0.86}, - TowerFrequency={filename="TowerFrequency.ogg", duration=1.19}, - Visibilty={filename="Visibility.ogg", duration=0.79}, - WeatherPhenomena={filename="WeatherPhenomena.ogg", duration=1.07}, - WindFrom={filename="WindFrom.ogg", duration=0.60}, - ILSFrequency={filename="ILSFrequency.ogg", duration=1.30}, - InnerNDBFrequency={filename="InnerNDBFrequency.ogg", duration=1.56}, - OuterNDBFrequency={filename="OuterNDBFrequency.ogg", duration=1.59}, - RunwayLength={filename="RunwayLength.ogg", duration=0.91}, - VORFrequency={filename="VORFrequency.ogg", duration=1.38}, - TACANChannel={filename="TACANChannel.ogg", duration=0.88}, - PRMGChannel={filename="PRMGChannel.ogg", duration=1.18}, - RSBNChannel={filename="RSBNChannel.ogg", duration=1.14}, - Zulu={filename="Zulu.ogg", duration=0.62}, + ActiveRunway = { filename = "ActiveRunway.ogg", duration = 0.99 }, + AdviceOnInitial = { filename = "AdviceOnInitial.ogg", duration = 3.00 }, + Airport = { filename = "Airport.ogg", duration = 0.66 }, + Altimeter = { filename = "Altimeter.ogg", duration = 0.68 }, + At = { filename = "At.ogg", duration = 0.41 }, + CloudBase = { filename = "CloudBase.ogg", duration = 0.82 }, + CloudCeiling = { filename = "CloudCeiling.ogg", duration = 0.61 }, + CloudsBroken = { filename = "CloudsBroken.ogg", duration = 1.07 }, + CloudsFew = { filename = "CloudsFew.ogg", duration = 0.99 }, + CloudsNo = { filename = "CloudsNo.ogg", duration = 1.01 }, + CloudsNotAvailable = { filename = "CloudsNotAvailable.ogg", duration = 2.35 }, + CloudsOvercast = { filename = "CloudsOvercast.ogg", duration = 0.83 }, + CloudsScattered = { filename = "CloudsScattered.ogg", duration = 1.18 }, + Decimal = { filename = "Decimal.ogg", duration = 0.54 }, + DegreesCelsius = { filename = "DegreesCelsius.ogg", duration = 1.27 }, + DegreesFahrenheit = { filename = "DegreesFahrenheit.ogg", duration = 1.23 }, + DewPoint = { filename = "DewPoint.ogg", duration = 0.65 }, + Dust = { filename = "Dust.ogg", duration = 0.54 }, + Elevation = { filename = "Elevation.ogg", duration = 0.78 }, + EndOfInformation = { filename = "EndOfInformation.ogg", duration = 1.15 }, + Feet = { filename = "Feet.ogg", duration = 0.45 }, + Fog = { filename = "Fog.ogg", duration = 0.47 }, + Gusting = { filename = "Gusting.ogg", duration = 0.55 }, + HectoPascal = { filename = "HectoPascal.ogg", duration = 1.15 }, + Hundred = { filename = "Hundred.ogg", duration = 0.47 }, + InchesOfMercury = { filename = "InchesOfMercury.ogg", duration = 1.16 }, + Information = { filename = "Information.ogg", duration = 0.85 }, + Kilometers = { filename = "Kilometers.ogg", duration = 0.78 }, + Knots = { filename = "Knots.ogg", duration = 0.59 }, + Left = { filename = "Left.ogg", duration = 0.54 }, + MegaHertz = { filename = "MegaHertz.ogg", duration = 0.87 }, + Meters = { filename = "Meters.ogg", duration = 0.59 }, + MetersPerSecond = { filename = "MetersPerSecond.ogg", duration = 1.14 }, + Miles = { filename = "Miles.ogg", duration = 0.60 }, + MillimetersOfMercury = { filename = "MillimetersOfMercury.ogg", duration = 1.53 }, + Minus = { filename = "Minus.ogg", duration = 0.64 }, + N0 = { filename = "N-0.ogg", duration = 0.55 }, + N1 = { filename = "N-1.ogg", duration = 0.41 }, + N2 = { filename = "N-2.ogg", duration = 0.37 }, + N3 = { filename = "N-3.ogg", duration = 0.41 }, + N4 = { filename = "N-4.ogg", duration = 0.37 }, + N5 = { filename = "N-5.ogg", duration = 0.43 }, + N6 = { filename = "N-6.ogg", duration = 0.55 }, + N7 = { filename = "N-7.ogg", duration = 0.43 }, + N8 = { filename = "N-8.ogg", duration = 0.38 }, + N9 = { filename = "N-9.ogg", duration = 0.55 }, + NauticalMiles = { filename = "NauticalMiles.ogg", duration = 1.04 }, + None = { filename = "None.ogg", duration = 0.43 }, + QFE = { filename = "QFE.ogg", duration = 0.63 }, + QNH = { filename = "QNH.ogg", duration = 0.71 }, + Rain = { filename = "Rain.ogg", duration = 0.41 }, + Right = { filename = "Right.ogg", duration = 0.44 }, + Snow = { filename = "Snow.ogg", duration = 0.48 }, + SnowStorm = { filename = "SnowStorm.ogg", duration = 0.82 }, + StatuteMiles = { filename = "StatuteMiles.ogg", duration = 1.15 }, + SunriseAt = { filename = "SunriseAt.ogg", duration = 0.92 }, + SunsetAt = { filename = "SunsetAt.ogg", duration = 0.95 }, + Temperature = { filename = "Temperature.ogg", duration = 0.64 }, + Thousand = { filename = "Thousand.ogg", duration = 0.55 }, + ThunderStorm = { filename = "ThunderStorm.ogg", duration = 0.81 }, + TimeLocal = { filename = "TimeLocal.ogg", duration = 0.90 }, + TimeZulu = { filename = "TimeZulu.ogg", duration = 0.86 }, + TowerFrequency = { filename = "TowerFrequency.ogg", duration = 1.19 }, + Visibilty = { filename = "Visibility.ogg", duration = 0.79 }, + WeatherPhenomena = { filename = "WeatherPhenomena.ogg", duration = 1.07 }, + WindFrom = { filename = "WindFrom.ogg", duration = 0.60 }, + ILSFrequency = { filename = "ILSFrequency.ogg", duration = 1.30 }, + InnerNDBFrequency = { filename = "InnerNDBFrequency.ogg", duration = 1.56 }, + OuterNDBFrequency = { filename = "OuterNDBFrequency.ogg", duration = 1.59 }, + RunwayLength = { filename = "RunwayLength.ogg", duration = 0.91 }, + VORFrequency = { filename = "VORFrequency.ogg", duration = 1.38 }, + TACANChannel = { filename = "TACANChannel.ogg", duration = 0.88 }, + PRMGChannel = { filename = "PRMGChannel.ogg", duration = 1.18 }, + RSBNChannel = { filename = "RSBNChannel.ogg", duration = 1.14 }, + Zulu = { filename = "Zulu.ogg", duration = 0.62 }, } - --- ATIS table containing all defined ATISes. -- @field #table _ATIS -_ATIS={} +_ATIS = {} --- ATIS class version. -- @field #string version -ATIS.version="0.9.6" +ATIS.version = "0.9.6" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -618,31 +617,31 @@ ATIS.version="0.9.6" -- @param #number frequency Radio frequency in MHz. Default 143.00 MHz. -- @param #number modulation Radio modulation: 0=AM, 1=FM. Default 0=AM. See `radio.modulation.AM` and `radio.modulation.FM` enumerators -- @return #ATIS self -function ATIS:New(airbasename, frequency, modulation) +function ATIS:New( airbasename, frequency, modulation ) -- Inherit everything from FSM class. - local self=BASE:Inherit(self, FSM:New()) -- #ATIS + local self = BASE:Inherit( self, FSM:New() ) -- #ATIS - self.airbasename=airbasename - self.airbase=AIRBASE:FindByName(airbasename) + self.airbasename = airbasename + self.airbase = AIRBASE:FindByName( airbasename ) - if self.airbase==nil then - self:E("ERROR: Airbase %s for ATIS could not be found!", tostring(airbasename)) + if self.airbase == nil then + self:E( "ERROR: Airbase %s for ATIS could not be found!", tostring( airbasename ) ) return nil end -- Default freq and modulation. - self.frequency=frequency or 143.00 - self.modulation=modulation or 0 + self.frequency = frequency or 143.00 + self.modulation = modulation or 0 -- Get map. - self.theatre=env.mission.theatre + self.theatre = env.mission.theatre -- Set some string id for output to DCS.log file. - self.lid=string.format("ATIS %s | ", self.airbasename) + self.lid = string.format( "ATIS %s | ", self.airbasename ) -- This is just to hinder the garbage collector deallocating the ATIS object. - _ATIS[#_ATIS+1]=self + _ATIS[#_ATIS + 1] = self -- Defaults: self:SetSoundfilesPath() @@ -650,13 +649,13 @@ function ATIS:New(airbasename, frequency, modulation) self:SetMagneticDeclination() self:SetRunwayCorrectionMagnetic2True() self:SetRadioPower() - self:SetAltimeterQNH(true) - self:SetMapMarks(false) + self:SetAltimeterQNH( true ) + self:SetMapMarks( false ) self:SetRelativeHumidity() self:SetQueueUpdateTime() -- Start State. - self:SetStartState("Stopped") + self:SetStartState( "Stopped" ) -- Add FSM transitions. -- From State --> Event --> To State @@ -680,7 +679,6 @@ function ATIS:New(airbasename, frequency, modulation) -- @param #ATIS self -- @param #number delay Delay in seconds. - --- Triggers the FSM event "Stop". Stops the ATIS. -- @function [parent=#ATIS] Stop -- @param #ATIS self @@ -690,7 +688,6 @@ function ATIS:New(airbasename, frequency, modulation) -- @param #ATIS self -- @param #number delay Delay in seconds. - --- Triggers the FSM event "Status". -- @function [parent=#ATIS] Status -- @param #ATIS self @@ -700,7 +697,6 @@ function ATIS:New(airbasename, frequency, modulation) -- @param #ATIS self -- @param #number delay Delay in seconds. - --- Triggers the FSM event "Broadcast". -- @function [parent=#ATIS] Broadcast -- @param #ATIS self @@ -710,7 +706,6 @@ function ATIS:New(airbasename, frequency, modulation) -- @param #ATIS self -- @param #number delay Delay in seconds. - --- Triggers the FSM event "CheckQueue". -- @function [parent=#ATIS] CheckQueue -- @param #ATIS self @@ -720,7 +715,6 @@ function ATIS:New(airbasename, frequency, modulation) -- @param #ATIS self -- @param #number delay Delay in seconds. - --- Triggers the FSM event "Report". -- @function [parent=#ATIS] Report -- @param #ATIS self @@ -740,13 +734,12 @@ function ATIS:New(airbasename, frequency, modulation) -- @param #string To To state. -- @param #string Text Report text. - -- Debug trace. if false then - self.Debug=true - BASE:TraceOnOff(true) - BASE:TraceClass(self.ClassName) - BASE:TraceLevel(1) + self.Debug = true + BASE:TraceOnOff( true ) + BASE:TraceClass( self.ClassName ) + BASE:TraceLevel( 1 ) end return self @@ -760,9 +753,9 @@ end -- @param #ATIS self -- @param #string path Path for sound files. Default "ATIS Soundfiles/". Mind the slash "/" at the end! -- @return #ATIS self -function ATIS:SetSoundfilesPath(path) - self.soundpath=tostring(path or "ATIS Soundfiles/") - self:I(self.lid..string.format("Setting sound files path to %s", self.soundpath)) +function ATIS:SetSoundfilesPath( path ) + self.soundpath = tostring( path or "ATIS Soundfiles/" ) + self:I( self.lid .. string.format( "Setting sound files path to %s", self.soundpath ) ) return self end @@ -771,9 +764,9 @@ end -- @param #ATIS self -- @param #string unitname Name of the unit. -- @return #ATIS self -function ATIS:SetRadioRelayUnitName(unitname) - self.relayunitname=unitname - self:I(self.lid..string.format("Setting radio relay unit to %s", self.relayunitname)) +function ATIS:SetRadioRelayUnitName( unitname ) + self.relayunitname = unitname + self:I( self.lid .. string.format( "Setting radio relay unit to %s", self.relayunitname ) ) return self end @@ -781,13 +774,13 @@ end -- @param #ATIS self -- @param #table freqs Table of frequencies in MHz. A single frequency can be given as a plain number (*i.e.* must not be table). -- @return #ATIS self -function ATIS:SetTowerFrequencies(freqs) - if type(freqs)=="table" then +function ATIS:SetTowerFrequencies( freqs ) + if type( freqs ) == "table" then -- nothing to do else - freqs={freqs} + freqs = { freqs } end - self.towerfrequency=freqs + self.towerfrequency = freqs return self end @@ -796,8 +789,8 @@ end -- @param #ATIS self -- @param #string runway Active runway, *e.g.* "31L". -- @return #ATIS self -function ATIS:SetActiveRunway(runway) - self.activerunway=tostring(runway) +function ATIS:SetActiveRunway( runway ) + self.activerunway = tostring( runway ) return self end @@ -805,7 +798,7 @@ end -- @param #ATIS self -- @return #ATIS self function ATIS:SetRunwayLength() - self.rwylength=true + self.rwylength = true return self end @@ -813,7 +806,7 @@ end -- @param #ATIS self -- @return #ATIS self function ATIS:SetElevation() - self.elevation=true + self.elevation = true return self end @@ -821,8 +814,8 @@ end -- @param #ATIS self -- @param #number power Radio power in Watts. Default 100 W. -- @return #ATIS self -function ATIS:SetRadioPower(power) - self.power=power or 100 +function ATIS:SetRadioPower( power ) + self.power = power or 100 return self end @@ -830,11 +823,11 @@ end -- @param #ATIS self -- @param #boolean switch If *true* or *nil*, marks are placed on F10 map. If *false* this feature is set to off (default). -- @return #ATIS self -function ATIS:SetMapMarks(switch) - if switch==nil or switch==true then - self.usemarker=true +function ATIS:SetMapMarks( switch ) + if switch == nil or switch == true then + self.usemarker = true else - self.usemarker=false + self.usemarker = false end return self end @@ -843,46 +836,46 @@ end -- @param #ATIS self -- @param #table headings Magnetic headings. Inverse (-180°) headings are added automatically. You only need to specify one heading per runway direction. "L"eft and "R" right can also be appended. -- @return #ATIS self -function ATIS:SetRunwayHeadingsMagnetic(headings) +function ATIS:SetRunwayHeadingsMagnetic( headings ) -- First make sure, we have a table. - if type(headings)=="table" then + if type( headings ) == "table" then -- nothing to do else - headings={headings} + headings = { headings } end - for _,heading in pairs(headings) do + for _, heading in pairs( headings ) do - if type(heading)=="number" then - heading=string.format("%02d", heading) + if type( heading ) == "number" then + heading = string.format( "%02d", heading ) end -- Add runway heading to table. - self:I(self.lid..string.format("Adding user specified magnetic runway heading %s", heading)) - table.insert(self.runwaymag, heading) + self:I( self.lid .. string.format( "Adding user specified magnetic runway heading %s", heading ) ) + table.insert( self.runwaymag, heading ) - local h=self:GetRunwayWithoutLR(heading) + local h = self:GetRunwayWithoutLR( heading ) - local head2=tonumber(h)-18 - if head2<0 then - head2=head2+36 + local head2 = tonumber( h ) - 18 + if head2 < 0 then + head2 = head2 + 36 end -- Convert to string. - head2=string.format("%02d", head2) + head2 = string.format( "%02d", head2 ) -- Append "L" or "R" if necessary. - local left=self:GetRunwayLR(heading) - if left==true then - head2=head2.."L" - elseif left==false then - head2=head2.."R" + local left = self:GetRunwayLR( heading ) + if left == true then + head2 = head2 .. "L" + elseif left == false then + head2 = head2 .. "R" end -- Add inverse runway heading to table. - self:I(self.lid..string.format("Adding user specified magnetic runway heading %s (inverse)", head2)) - table.insert(self.runwaymag, head2) + self:I( self.lid .. string.format( "Adding user specified magnetic runway heading %s (inverse)", head2 ) ) + table.insert( self.runwaymag, head2 ) end return self @@ -892,8 +885,8 @@ end -- @param #ATIS self -- @param #number duration Duration in seconds. Default 10 seconds. -- @return #ATIS self -function ATIS:SetSubtitleDuration(duration) - self.subduration=tonumber(duration or 10) +function ATIS:SetSubtitleDuration( duration ) + self.subduration = tonumber( duration or 10 ) return self end @@ -901,7 +894,7 @@ end -- @param #ATIS self -- @return #ATIS self function ATIS:SetMetricUnits() - self.metric=true + self.metric = true return self end @@ -909,7 +902,7 @@ end -- @param #ATIS self -- @return #ATIS self function ATIS:SetImperialUnits() - self.metric=false + self.metric = false return self end @@ -918,7 +911,7 @@ end -- @param #ATIS self -- @return #ATIS self function ATIS:SetPressureMillimetersMercury() - self.PmmHg=true + self.PmmHg = true return self end @@ -926,7 +919,7 @@ end -- @param #ATIS self -- @return #ATIS self function ATIS:SetTemperatureFahrenheit() - self.TDegF=true + self.TDegF = true return self end @@ -935,8 +928,8 @@ end -- @param #ATIS self -- @param #number Humidity Relative Humidity, i.e. a number between 0 and 100 %. Default is 50 %. -- @return #ATIS self -function ATIS:SetRelativeHumidity(Humidity) - self.relHumidity=Humidity or 50 +function ATIS:SetRelativeHumidity( Humidity ) + self.relHumidity = Humidity or 50 return self end @@ -944,12 +937,12 @@ end -- @param #ATIS self -- @param #boolean switch If true or nil, report altimeter QHN. If false, report QFF. -- @return #ATIS self -function ATIS:SetAltimeterQNH(switch) +function ATIS:SetAltimeterQNH( switch ) - if switch==true or switch==nil then - self.altimeterQNH=true + if switch == true or switch == nil then + self.altimeterQNH = true else - self.altimeterQNH=false + self.altimeterQNH = false end return self @@ -959,7 +952,7 @@ end -- @param #ATIS self -- @return #ATIS self function ATIS:ReportQNHOnly() - self.qnhonly=true + self.qnhonly = true return self end @@ -988,8 +981,8 @@ end -- @param #ATIS self -- @param #number magvar Magnetic variation in degrees. Positive for easterly and negative for westerly variation. Default is magnatic declinaton of the used map, c.f. @{Utilities.UTils#UTILS.GetMagneticDeclination}. -- @return #ATIS self -function ATIS:SetMagneticDeclination(magvar) - self.magvar=magvar or UTILS.GetMagneticDeclination() +function ATIS:SetMagneticDeclination( magvar ) + self.magvar = magvar or UTILS.GetMagneticDeclination() return self end @@ -997,8 +990,8 @@ end -- @param #ATIS self -- @param #number correction Correction of magnetic to true heading for runways in degrees. -- @return #ATIS self -function ATIS:SetRunwayCorrectionMagnetic2True(correction) - self.runwaym2t=correction or ATIS.RunwayM2T[UTILS.GetDCSMap()] +function ATIS:SetRunwayCorrectionMagnetic2True( correction ) + self.runwaym2t = correction or ATIS.RunwayM2T[UTILS.GetDCSMap()] return self end @@ -1006,7 +999,7 @@ end -- @param #ATIS self -- @return #ATIS self function ATIS:SetReportWindTrue() - self.windtrue=true + self.windtrue = true return self end @@ -1022,8 +1015,8 @@ end -- @param #ATIS self -- @param #number delta Time difference in hours. -- @return #ATIS self -function ATIS:SetZuluTimeDifference(delta) - self.zuludiff=delta +function ATIS:SetZuluTimeDifference( delta ) + self.zuludiff = delta return self end @@ -1031,7 +1024,7 @@ end -- @param #ATIS self -- @return #ATIS self function ATIS:ReportZuluTimeOnly() - self.zulutimeonly=true + self.zulutimeonly = true return self end @@ -1040,11 +1033,11 @@ end -- @param #number frequency ILS frequency in MHz. -- @param #string runway (Optional) Runway for which the given ILS frequency applies. Default all (*nil*). -- @return #ATIS self -function ATIS:AddILS(frequency, runway) - local ils={} --#ATIS.NavPoint - ils.frequency=tonumber(frequency) - ils.runway=runway and tostring(runway) or nil - table.insert(self.ils, ils) +function ATIS:AddILS( frequency, runway ) + local ils = {} -- #ATIS.NavPoint + ils.frequency = tonumber( frequency ) + ils.runway = runway and tostring( runway ) or nil + table.insert( self.ils, ils ) return self end @@ -1052,8 +1045,8 @@ end -- @param #ATIS self -- @param #number frequency VOR frequency. -- @return #ATIS self -function ATIS:SetVOR(frequency) - self.vor=frequency +function ATIS:SetVOR( frequency ) + self.vor = frequency return self end @@ -1062,11 +1055,11 @@ end -- @param #number frequency NDB frequency in MHz. -- @param #string runway (Optional) Runway for which the given NDB frequency applies. Default all (*nil*). -- @return #ATIS self -function ATIS:AddNDBouter(frequency, runway) - local ndb={} --#ATIS.NavPoint - ndb.frequency=tonumber(frequency) - ndb.runway=runway and tostring(runway) or nil - table.insert(self.ndbouter, ndb) +function ATIS:AddNDBouter( frequency, runway ) + local ndb = {} -- #ATIS.NavPoint + ndb.frequency = tonumber( frequency ) + ndb.runway = runway and tostring( runway ) or nil + table.insert( self.ndbouter, ndb ) return self end @@ -1075,11 +1068,11 @@ end -- @param #number frequency NDB frequency in MHz. -- @param #string runway (Optional) Runway for which the given NDB frequency applies. Default all (*nil*). -- @return #ATIS self -function ATIS:AddNDBinner(frequency, runway) - local ndb={} --#ATIS.NavPoint - ndb.frequency=tonumber(frequency) - ndb.runway=runway and tostring(runway) or nil - table.insert(self.ndbinner, ndb) +function ATIS:AddNDBinner( frequency, runway ) + local ndb = {} -- #ATIS.NavPoint + ndb.frequency = tonumber( frequency ) + ndb.runway = runway and tostring( runway ) or nil + table.insert( self.ndbinner, ndb ) return self end @@ -1087,8 +1080,8 @@ end -- @param #ATIS self -- @param #number channel TACAN channel. -- @return #ATIS self -function ATIS:SetTACAN(channel) - self.tacan=channel +function ATIS:SetTACAN( channel ) + self.tacan = channel return self end @@ -1096,8 +1089,8 @@ end -- @param #ATIS self -- @param #number channel RSBN channel. -- @return #ATIS self -function ATIS:SetRSBN(channel) - self.rsbn=channel +function ATIS:SetRSBN( channel ) + self.rsbn = channel return self end @@ -1106,24 +1099,23 @@ end -- @param #number channel PRMG channel. -- @param #string runway (Optional) Runway for which the given PRMG channel applies. Default all (*nil*). -- @return #ATIS self -function ATIS:AddPRMG(channel, runway) - local ndb={} --#ATIS.NavPoint - ndb.frequency=tonumber(channel) - ndb.runway=runway and tostring(runway) or nil - table.insert(self.prmg, ndb) +function ATIS:AddPRMG( channel, runway ) + local ndb = {} -- #ATIS.NavPoint + ndb.frequency = tonumber( channel ) + ndb.runway = runway and tostring( runway ) or nil + table.insert( self.prmg, ndb ) return self end - --- Place marks with runway data on the F10 map. -- @param #ATIS self -- @param #boolean markall If true, mark all runways of the map. By default only the current ATIS runways are marked. -function ATIS:MarkRunways(markall) - local airbases=AIRBASE.GetAllAirbases() - for _,_airbase in pairs(airbases) do - local airbase=_airbase --Wrapper.Airbase#AIRBASE - if (not markall and airbase:GetName()==self.airbasename) or markall==true then - airbase:GetRunwayData(self.runwaym2t, true) +function ATIS:MarkRunways( markall ) + local airbases = AIRBASE.GetAllAirbases() + for _, _airbase in pairs( airbases ) do + local airbase = _airbase -- Wrapper.Airbase#AIRBASE + if (not markall and airbase:GetName() == self.airbasename) or markall == true then + airbase:GetRunwayData( self.runwaym2t, true ) end end end @@ -1136,16 +1128,16 @@ end -- @param #string Voice Specific voice. Overrides `Gender` and `Culture`. -- @param #number Port SRS port. Default 5002. -- @return #ATIS self -function ATIS:SetSRS(PathToSRS, Gender, Culture, Voice, Port) - self.useSRS=true - self.msrs=MSRS:New(PathToSRS, self.frequency, self.modulation) - self.msrs:SetGender(Gender) - self.msrs:SetCulture(Culture) - self.msrs:SetVoice(Voice) - self.msrs:SetPort(Port) - self.msrs:SetCoalition(self:GetCoalition()) - if self.dTQueueCheck<=10 then - self:SetQueueUpdateTime(90) +function ATIS:SetSRS( PathToSRS, Gender, Culture, Voice, Port ) + self.useSRS = true + self.msrs = MSRS:New( PathToSRS, self.frequency, self.modulation ) + self.msrs:SetGender( Gender ) + self.msrs:SetCulture( Culture ) + self.msrs:SetVoice( Voice ) + self.msrs:SetPort( Port ) + self.msrs:SetCoalition( self:GetCoalition() ) + if self.dTQueueCheck <= 10 then + self:SetQueueUpdateTime( 90 ) end return self end @@ -1154,15 +1146,15 @@ end -- @param #ATIS self -- @param #number TimeInterval Interval in seconds. Default 5 sec. -- @return #ATIS self -function ATIS:SetQueueUpdateTime(TimeInterval) - self.dTQueueCheck=TimeInterval or 5 +function ATIS:SetQueueUpdateTime( TimeInterval ) + self.dTQueueCheck = TimeInterval or 5 end --- Get the coalition of the associated airbase. -- @param #ATIS self -- @return #number Coalition of the associcated airbase. function ATIS:GetCoalition() - local coal=self.airbase and self.airbase:GetCoalition() or nil + local coal = self.airbase and self.airbase:GetCoalition() or nil return coal end @@ -1175,51 +1167,51 @@ end -- @param #string From From state. -- @param #string Event Event. -- @param #string To To state. -function ATIS:onafterStart(From, Event, To) +function ATIS:onafterStart( From, Event, To ) -- Check that this is an airdrome. - if self.airbase:GetAirbaseCategory()~=Airbase.Category.AIRDROME then - self:E(self.lid..string.format("ERROR: Cannot start ATIS for airbase %s! Only AIRDROMES are supported but NOT FARPS or SHIPS.", self.airbasename)) + if self.airbase:GetAirbaseCategory() ~= Airbase.Category.AIRDROME then + self:E( self.lid .. string.format( "ERROR: Cannot start ATIS for airbase %s! Only AIRDROMES are supported but NOT FARPS or SHIPS.", self.airbasename ) ) return end -- Info. - self:I(self.lid..string.format("Starting ATIS v%s for airbase %s on %.3f MHz Modulation=%d", ATIS.version, self.airbasename, self.frequency, self.modulation)) + self:I( self.lid .. string.format( "Starting ATIS v%s for airbase %s on %.3f MHz Modulation=%d", ATIS.version, self.airbasename, self.frequency, self.modulation ) ) -- Start radio queue. - self.radioqueue=RADIOQUEUE:New(self.frequency, self.modulation, string.format("ATIS %s", self.airbasename)) + self.radioqueue = RADIOQUEUE:New( self.frequency, self.modulation, string.format( "ATIS %s", self.airbasename ) ) -- Send coordinate is airbase coord. - self.radioqueue:SetSenderCoordinate(self.airbase:GetCoordinate()) + self.radioqueue:SetSenderCoordinate( self.airbase:GetCoordinate() ) -- Set relay unit if we have one. - self.radioqueue:SetSenderUnitName(self.relayunitname) + self.radioqueue:SetSenderUnitName( self.relayunitname ) -- Set radio power. - self.radioqueue:SetRadioPower(self.power) + self.radioqueue:SetRadioPower( self.power ) -- Init numbers. - self.radioqueue:SetDigit(0, ATIS.Sound.N0.filename, ATIS.Sound.N0.duration, self.soundpath) - self.radioqueue:SetDigit(1, ATIS.Sound.N1.filename, ATIS.Sound.N1.duration, self.soundpath) - self.radioqueue:SetDigit(2, ATIS.Sound.N2.filename, ATIS.Sound.N2.duration, self.soundpath) - self.radioqueue:SetDigit(3, ATIS.Sound.N3.filename, ATIS.Sound.N3.duration, self.soundpath) - self.radioqueue:SetDigit(4, ATIS.Sound.N4.filename, ATIS.Sound.N4.duration, self.soundpath) - self.radioqueue:SetDigit(5, ATIS.Sound.N5.filename, ATIS.Sound.N5.duration, self.soundpath) - self.radioqueue:SetDigit(6, ATIS.Sound.N6.filename, ATIS.Sound.N6.duration, self.soundpath) - self.radioqueue:SetDigit(7, ATIS.Sound.N7.filename, ATIS.Sound.N7.duration, self.soundpath) - self.radioqueue:SetDigit(8, ATIS.Sound.N8.filename, ATIS.Sound.N8.duration, self.soundpath) - self.radioqueue:SetDigit(9, ATIS.Sound.N9.filename, ATIS.Sound.N9.duration, self.soundpath) + self.radioqueue:SetDigit( 0, ATIS.Sound.N0.filename, ATIS.Sound.N0.duration, self.soundpath ) + self.radioqueue:SetDigit( 1, ATIS.Sound.N1.filename, ATIS.Sound.N1.duration, self.soundpath ) + self.radioqueue:SetDigit( 2, ATIS.Sound.N2.filename, ATIS.Sound.N2.duration, self.soundpath ) + self.radioqueue:SetDigit( 3, ATIS.Sound.N3.filename, ATIS.Sound.N3.duration, self.soundpath ) + self.radioqueue:SetDigit( 4, ATIS.Sound.N4.filename, ATIS.Sound.N4.duration, self.soundpath ) + self.radioqueue:SetDigit( 5, ATIS.Sound.N5.filename, ATIS.Sound.N5.duration, self.soundpath ) + self.radioqueue:SetDigit( 6, ATIS.Sound.N6.filename, ATIS.Sound.N6.duration, self.soundpath ) + self.radioqueue:SetDigit( 7, ATIS.Sound.N7.filename, ATIS.Sound.N7.duration, self.soundpath ) + self.radioqueue:SetDigit( 8, ATIS.Sound.N8.filename, ATIS.Sound.N8.duration, self.soundpath ) + self.radioqueue:SetDigit( 9, ATIS.Sound.N9.filename, ATIS.Sound.N9.duration, self.soundpath ) -- Start radio queue. - self.radioqueue:Start(1, 0.1) - + self.radioqueue:Start( 1, 0.1 ) + -- Handle airbase capture -- Handle events. - self:HandleEvent(EVENTS.BaseCaptured) + self:HandleEvent( EVENTS.BaseCaptured ) -- Init status updates. - self:__Status(-2) - self:__CheckQueue(-3) + self:__Status( -2 ) + self:__CheckQueue( -3 ) end --- Update status. @@ -1227,30 +1219,29 @@ end -- @param #string From From state. -- @param #string Event Event. -- @param #string To To state. -function ATIS:onafterStatus(From, Event, To) +function ATIS:onafterStatus( From, Event, To ) -- Get FSM state. - local fsmstate=self:GetState() + local fsmstate = self:GetState() - local relayunitstatus="N/A" + local relayunitstatus = "N/A" if self.relayunitname then - local ru=UNIT:FindByName(self.relayunitname) + local ru = UNIT:FindByName( self.relayunitname ) if ru then - relayunitstatus=tostring(ru:IsAlive()) + relayunitstatus = tostring( ru:IsAlive() ) end end - -- Info text. - local text=string.format("State %s: Freq=%.3f MHz %s", fsmstate, self.frequency, UTILS.GetModulationName(self.modulation)) + -- Info text. + local text = string.format( "State %s: Freq=%.3f MHz %s", fsmstate, self.frequency, UTILS.GetModulationName( self.modulation ) ) if self.useSRS then - text=text..string.format(", SRS path=%s (%s), gender=%s, culture=%s, voice=%s", - tostring(self.msrs.path), tostring(self.msrs.port), tostring(self.msrs.gender), tostring(self.msrs.culture), tostring(self.msrs.voice)) + text = text .. string.format( ", SRS path=%s (%s), gender=%s, culture=%s, voice=%s", tostring( self.msrs.path ), tostring( self.msrs.port ), tostring( self.msrs.gender ), tostring( self.msrs.culture ), tostring( self.msrs.voice ) ) else - text=text..string.format(", Relay unit=%s (alive=%s)", tostring(self.relayunitname), relayunitstatus) + text = text .. string.format( ", Relay unit=%s (alive=%s)", tostring( self.relayunitname ), relayunitstatus ) end - self:I(self.lid..text) + self:I( self.lid .. text ) - self:__Status(-60) + self:__Status( -60 ) end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -1262,27 +1253,25 @@ end -- @param #string From From state. -- @param #string Event Event. -- @param #string To To state. -function ATIS:onafterCheckQueue(From, Event, To) +function ATIS:onafterCheckQueue( From, Event, To ) if self.useSRS then - + self:Broadcast() - + else - - if #self.radioqueue.queue==0 then - self:T(self.lid..string.format("Radio queue empty. Repeating message.")) + + if #self.radioqueue.queue == 0 then + self:T( self.lid .. string.format( "Radio queue empty. Repeating message." ) ) self:Broadcast() else - self:T2(self.lid..string.format("Radio queue %d transmissions queued.", #self.radioqueue.queue)) + self:T2( self.lid .. string.format( "Radio queue %d transmissions queued.", #self.radioqueue.queue ) ) end - - - + end -- Check back in 5 seconds. - self:__CheckQueue(-math.abs(self.dTQueueCheck)) + self:__CheckQueue( -math.abs( self.dTQueueCheck ) ) end --- Broadcast ATIS radio message. @@ -1290,69 +1279,67 @@ end -- @param #string From From state. -- @param #string Event Event. -- @param #string To To state. -function ATIS:onafterBroadcast(From, Event, To) +function ATIS:onafterBroadcast( From, Event, To ) -- Get current coordinate. - local coord=self.airbase:GetCoordinate() + local coord = self.airbase:GetCoordinate() -- Get elevation. - local height=coord:GetLandHeight() + local height = coord:GetLandHeight() ---------------- --- Pressure --- ---------------- -- Pressure in hPa. - local qfe=coord:GetPressure(height) - local qnh=coord:GetPressure(0) + local qfe = coord:GetPressure( height ) + local qnh = coord:GetPressure( 0 ) if self.altimeterQNH then -- Some constants. - local L=-0.0065 --[K/m] - local R= 8.31446 --[J/mol/K] - local g= 9.80665 --[m/s^2] - local M= 0.0289644 --[kg/mol] - local T0=coord:GetTemperature(0)+273.15 --[K] Temp at sea level. - local TS=288.15 -- Standard Temperature assumed by Altimeter is 15°C - local q=qnh*100 + local L = -0.0065 -- [K/m] + local R = 8.31446 -- [J/mol/K] + local g = 9.80665 -- [m/s^2] + local M = 0.0289644 -- [kg/mol] + local T0 = coord:GetTemperature( 0 ) + 273.15 -- [K] Temp at sea level. + local TS = 288.15 -- Standard Temperature assumed by Altimeter is 15°C + local q = qnh * 100 -- Calculate Pressure. - local P=q*(1+L*height/T0)^(-g*M/(R*L)) -- Pressure at sea level - local Q=P/(1+L*height/TS)^(-g*M/(R*L)) -- Altimeter QNH - local A=(T0/L)*((P/q)^(((-R*L)/(g*M)))-1) -- Altitude check - + local P = q * (1 + L * height / T0) ^ (-g * M / (R * L)) -- Pressure at sea level + local Q = P / (1 + L * height / TS) ^ (-g * M / (R * L)) -- Altimeter QNH + local A = (T0 / L) * ((P / q) ^ (((-R * L) / (g * M))) - 1) -- Altitude check -- Debug aoutput - self:T2(self.lid..string.format("height=%.1f, A=%.1f, T0=%.1f, QFE=%.1f, QNH=%.1f, P=%.1f, Q=%.1f hPa = %.2f", height, A, T0-273.15, qfe, qnh, P/100, Q/100, UTILS.hPa2inHg(Q/100))) + self:T2( self.lid .. string.format( "height=%.1f, A=%.1f, T0=%.1f, QFE=%.1f, QNH=%.1f, P=%.1f, Q=%.1f hPa = %.2f", height, A, T0 - 273.15, qfe, qnh, P / 100, Q / 100, UTILS.hPa2inHg( Q / 100 ) ) ) -- Set QNH value in hPa. - qnh=Q/100 + qnh = Q / 100 end - -- Convert to inHg. if self.PmmHg then - qfe=UTILS.hPa2mmHg(qfe) - qnh=UTILS.hPa2mmHg(qnh) + qfe = UTILS.hPa2mmHg( qfe ) + qnh = UTILS.hPa2mmHg( qnh ) else if not self.metric then - qfe=UTILS.hPa2inHg(qfe) - qnh=UTILS.hPa2inHg(qnh) + qfe = UTILS.hPa2inHg( qfe ) + qnh = UTILS.hPa2inHg( qnh ) end end - local QFE=UTILS.Split(string.format("%.2f", qfe), ".") - local QNH=UTILS.Split(string.format("%.2f", qnh), ".") + local QFE = UTILS.Split( string.format( "%.2f", qfe ), "." ) + local QNH = UTILS.Split( string.format( "%.2f", qnh ), "." ) if self.PmmHg then - QFE=UTILS.Split(string.format("%.1f", qfe), ".") - QNH=UTILS.Split(string.format("%.1f", qnh), ".") + QFE = UTILS.Split( string.format( "%.1f", qfe ), "." ) + QNH = UTILS.Split( string.format( "%.1f", qnh ), "." ) else if self.metric then - QFE=UTILS.Split(string.format("%.1f", qfe), ".") - QNH=UTILS.Split(string.format("%.1f", qnh), ".") + QFE = UTILS.Split( string.format( "%.1f", qfe ), "." ) + QNH = UTILS.Split( string.format( "%.1f", qnh ), "." ) end end @@ -1361,126 +1348,124 @@ function ATIS:onafterBroadcast(From, Event, To) ------------ -- Get wind direction and speed in m/s. - local windFrom, windSpeed=coord:GetWind(height+10) + local windFrom, windSpeed = coord:GetWind( height + 10 ) -- Wind in magnetic or true. - local magvar=self.magvar + local magvar = self.magvar if self.windtrue then - magvar=0 + magvar = 0 end - windFrom=windFrom-magvar - + windFrom = windFrom - magvar + -- Correct negative values. - if windFrom<0 then - windFrom=windFrom+360 + if windFrom < 0 then + windFrom = windFrom + 360 end - local WINDFROM=string.format("%03d", windFrom) - local WINDSPEED=string.format("%d", UTILS.MpsToKnots(windSpeed)) - + local WINDFROM = string.format( "%03d", windFrom ) + local WINDSPEED = string.format( "%d", UTILS.MpsToKnots( windSpeed ) ) + -- Report North as 0. - if WINDFROM=="000" then - WINDFROM="360" + if WINDFROM == "000" then + WINDFROM = "360" end if self.metric then - WINDSPEED=string.format("%d", windSpeed) + WINDSPEED = string.format( "%d", windSpeed ) end -------------- --- Runway --- -------------- - local runway, rwyLeft=self:GetActiveRunway() + local runway, rwyLeft = self:GetActiveRunway() ------------ --- Time --- ------------ - local time=timer.getAbsTime() + local time = timer.getAbsTime() -- Conversion to Zulu time. if self.zuludiff then -- User specified. - time=time-self.zuludiff*60*60 + time = time - self.zuludiff * 60 * 60 else - time=time-UTILS.GMTToLocalTimeDifference()*60*60 + time = time - UTILS.GMTToLocalTimeDifference() * 60 * 60 end if time < 0 then - time = 24*60*60 + time --avoid negative time around midnight - end - - local clock=UTILS.SecondsToClock(time) - local zulu=UTILS.Split(clock, ":") - local ZULU=string.format("%s%s", zulu[1], zulu[2]) - if self.useSRS then - ZULU=string.format("%s hours", zulu[1]) + time = 24 * 60 * 60 + time -- avoid negative time around midnight end + local clock = UTILS.SecondsToClock( time ) + local zulu = UTILS.Split( clock, ":" ) + local ZULU = string.format( "%s%s", zulu[1], zulu[2] ) + if self.useSRS then + ZULU = string.format( "%s hours", zulu[1] ) + end -- NATO time stamp. 0=Alfa, 1=Bravo, 2=Charlie, etc. - local NATO=ATIS.Alphabet[tonumber(zulu[1])+1] + local NATO = ATIS.Alphabet[tonumber( zulu[1] ) + 1] -- Debug. - self:T3(string.format("clock=%s", tostring(clock))) - self:T3(string.format("zulu1=%s", tostring(zulu[1]))) - self:T3(string.format("zulu2=%s", tostring(zulu[2]))) - self:T3(string.format("ZULU =%s", tostring(ZULU))) - self:T3(string.format("NATO =%s", tostring(NATO))) + self:T3( string.format( "clock=%s", tostring( clock ) ) ) + self:T3( string.format( "zulu1=%s", tostring( zulu[1] ) ) ) + self:T3( string.format( "zulu2=%s", tostring( zulu[2] ) ) ) + self:T3( string.format( "ZULU =%s", tostring( ZULU ) ) ) + self:T3( string.format( "NATO =%s", tostring( NATO ) ) ) -------------------------- --- Sunrise and Sunset --- -------------------------- - local sunrise=coord:GetSunrise() - sunrise=UTILS.Split(sunrise, ":") - local SUNRISE=string.format("%s%s", sunrise[1], sunrise[2]) + local sunrise = coord:GetSunrise() + sunrise = UTILS.Split( sunrise, ":" ) + local SUNRISE = string.format( "%s%s", sunrise[1], sunrise[2] ) if self.useSRS then - SUNRISE=string.format("%s %s hours", sunrise[1], sunrise[2]) - end + SUNRISE = string.format( "%s %s hours", sunrise[1], sunrise[2] ) + end - local sunset=coord:GetSunset() - sunset=UTILS.Split(sunset, ":") - local SUNSET=string.format("%s%s", sunset[1], sunset[2]) + local sunset = coord:GetSunset() + sunset = UTILS.Split( sunset, ":" ) + local SUNSET = string.format( "%s%s", sunset[1], sunset[2] ) if self.useSRS then - SUNSET=string.format("%s %s hours", sunset[1], sunset[2]) - end - + SUNSET = string.format( "%s %s hours", sunset[1], sunset[2] ) + end --------------------------------- --- Temperature and Dew Point --- --------------------------------- -- Temperature in °C. - local temperature=coord:GetTemperature(height+5) - + local temperature = coord:GetTemperature( height + 5 ) + -- Dew point in °C. - local dewpoint=temperature-(100-self.relHumidity)/5 + local dewpoint = temperature - (100 - self.relHumidity) / 5 -- Convert to °F. if self.TDegF then - temperature=UTILS.CelsiusToFahrenheit(temperature) - dewpoint=UTILS.CelsiusToFahrenheit(dewpoint) + temperature = UTILS.CelsiusToFahrenheit( temperature ) + dewpoint = UTILS.CelsiusToFahrenheit( dewpoint ) end - local TEMPERATURE=string.format("%d", math.abs(temperature)) - local DEWPOINT=string.format("%d", math.abs(dewpoint)) + local TEMPERATURE = string.format( "%d", math.abs( temperature ) ) + local DEWPOINT = string.format( "%d", math.abs( dewpoint ) ) --------------- --- Weather --- --------------- -- Get mission weather info. Most of this is static. - local clouds, visibility, turbulence, fog, dust, static=self:GetMissionWeather() + local clouds, visibility, turbulence, fog, dust, static = self:GetMissionWeather() -- Check that fog is actually "thick" enough to reach the airport. If an airport is in the mountains, fog might not affect it as it is measured from sea level. - if fog and fog.thicknessUTILS.FeetToMeters(1500) then - dust=nil + if dust and height + 25 > UTILS.FeetToMeters( 1500 ) then + dust = nil end ------------------ @@ -1488,214 +1473,214 @@ function ATIS:onafterBroadcast(From, Event, To) ------------------ -- Get min visibility. - local visibilitymin=visibility + local visibilitymin = visibility if fog then - if fog.visibility 10 then - reportedviz=10 + reportedviz = 10 end - VISIBILITY=string.format("%d", reportedviz) + VISIBILITY = string.format( "%d", reportedviz ) else -- max reported visibility 10 NM - local reportedviz=UTILS.Round(UTILS.MetersToSM(visibilitymin)) + local reportedviz = UTILS.Round( UTILS.MetersToSM( visibilitymin ) ) if reportedviz > 10 then - reportedviz=10 + reportedviz = 10 end - VISIBILITY=string.format("%d", reportedviz) + VISIBILITY = string.format( "%d", reportedviz ) end -------------- --- Clouds --- -------------- - local cloudbase=clouds.base - local cloudceil=clouds.base+clouds.thickness - local clouddens=clouds.density + local cloudbase = clouds.base + local cloudceil = clouds.base + clouds.thickness + local clouddens = clouds.density -- Cloud preset (DCS 2.7) - local cloudspreset=clouds.preset or "Nothing" - - -- Precepitation: 0=None, 1=Rain, 2=Thunderstorm, 3=Snow, 4=Snowstorm. - local precepitation=0 + local cloudspreset = clouds.preset or "Nothing" - if cloudspreset:find("Preset10") then + -- Precepitation: 0=None, 1=Rain, 2=Thunderstorm, 3=Snow, 4=Snowstorm. + local precepitation = 0 + + if cloudspreset:find( "Preset10" ) then -- Scattered 5 - clouddens=4 - elseif cloudspreset:find("Preset11") then + clouddens = 4 + elseif cloudspreset:find( "Preset11" ) then -- Scattered 6 - clouddens=4 - elseif cloudspreset:find("Preset12") then + clouddens = 4 + elseif cloudspreset:find( "Preset12" ) then -- Scattered 7 - clouddens=4 - elseif cloudspreset:find("Preset13") then + clouddens = 4 + elseif cloudspreset:find( "Preset13" ) then -- Broken 1 - clouddens=7 - elseif cloudspreset:find("Preset14") then + clouddens = 7 + elseif cloudspreset:find( "Preset14" ) then -- Broken 2 - clouddens=7 - elseif cloudspreset:find("Preset15") then + clouddens = 7 + elseif cloudspreset:find( "Preset15" ) then -- Broken 3 - clouddens=7 - elseif cloudspreset:find("Preset16") then + clouddens = 7 + elseif cloudspreset:find( "Preset16" ) then -- Broken 4 - clouddens=7 - elseif cloudspreset:find("Preset17") then + clouddens = 7 + elseif cloudspreset:find( "Preset17" ) then -- Broken 5 - clouddens=7 - elseif cloudspreset:find("Preset18") then + clouddens = 7 + elseif cloudspreset:find( "Preset18" ) then -- Broken 6 - clouddens=7 - elseif cloudspreset:find("Preset19") then + clouddens = 7 + elseif cloudspreset:find( "Preset19" ) then -- Broken 7 - clouddens=7 - elseif cloudspreset:find("Preset20") then + clouddens = 7 + elseif cloudspreset:find( "Preset20" ) then -- Broken 8 - clouddens=7 - elseif cloudspreset:find("Preset21") then + clouddens = 7 + elseif cloudspreset:find( "Preset21" ) then -- Overcast 1 - clouddens=9 - elseif cloudspreset:find("Preset22") then + clouddens = 9 + elseif cloudspreset:find( "Preset22" ) then -- Overcast 2 - clouddens=9 - elseif cloudspreset:find("Preset23") then + clouddens = 9 + elseif cloudspreset:find( "Preset23" ) then -- Overcast 3 - clouddens=9 - elseif cloudspreset:find("Preset24") then + clouddens = 9 + elseif cloudspreset:find( "Preset24" ) then -- Overcast 4 - clouddens=9 - elseif cloudspreset:find("Preset25") then + clouddens = 9 + elseif cloudspreset:find( "Preset25" ) then -- Overcast 5 - clouddens=9 - elseif cloudspreset:find("Preset26") then + clouddens = 9 + elseif cloudspreset:find( "Preset26" ) then -- Overcast 6 - clouddens=9 - elseif cloudspreset:find("Preset27") then + clouddens = 9 + elseif cloudspreset:find( "Preset27" ) then -- Overcast 7 - clouddens=9 - elseif cloudspreset:find("Preset1") then + clouddens = 9 + elseif cloudspreset:find( "Preset1" ) then -- Light Scattered 1 - clouddens=1 - elseif cloudspreset:find("Preset2") then + clouddens = 1 + elseif cloudspreset:find( "Preset2" ) then -- Light Scattered 2 - clouddens=1 - elseif cloudspreset:find("Preset3") then + clouddens = 1 + elseif cloudspreset:find( "Preset3" ) then -- High Scattered 1 - clouddens=4 - elseif cloudspreset:find("Preset4") then + clouddens = 4 + elseif cloudspreset:find( "Preset4" ) then -- High Scattered 2 - clouddens=4 - elseif cloudspreset:find("Preset5") then + clouddens = 4 + elseif cloudspreset:find( "Preset5" ) then -- Scattered 1 - clouddens=4 - elseif cloudspreset:find("Preset6") then + clouddens = 4 + elseif cloudspreset:find( "Preset6" ) then -- Scattered 2 - clouddens=4 - elseif cloudspreset:find("Preset7") then + clouddens = 4 + elseif cloudspreset:find( "Preset7" ) then -- Scattered 3 - clouddens=4 - elseif cloudspreset:find("Preset8") then + clouddens = 4 + elseif cloudspreset:find( "Preset8" ) then -- High Scattered 3 - clouddens=4 - elseif cloudspreset:find("Preset9") then + clouddens = 4 + elseif cloudspreset:find( "Preset9" ) then -- Scattered 4 - clouddens=4 - elseif cloudspreset:find("RainyPreset") then - -- Overcast + Rain - clouddens=9 - if temperature>5 then - precepitation=1 -- rain - else - precepitation=3 -- snow - end - elseif cloudspreset:find("RainyPreset1") then - -- Overcast + Rain - clouddens=9 - if temperature>5 then - precepitation=1 -- rain - else - precepitation=3 -- snow - end - elseif cloudspreset:find("RainyPreset2") then - -- Overcast + Rain - clouddens=9 - if temperature>5 then - precepitation=1 -- rain - else - precepitation=3 -- snow - end - elseif cloudspreset:find("RainyPreset3") then + clouddens = 4 + elseif cloudspreset:find( "RainyPreset" ) then -- Overcast + Rain - clouddens=9 - if temperature>5 then - precepitation=1 -- rain + clouddens = 9 + if temperature > 5 then + precepitation = 1 -- rain else - precepitation=3 -- snow + precepitation = 3 -- snow + end + elseif cloudspreset:find( "RainyPreset1" ) then + -- Overcast + Rain + clouddens = 9 + if temperature > 5 then + precepitation = 1 -- rain + else + precepitation = 3 -- snow + end + elseif cloudspreset:find( "RainyPreset2" ) then + -- Overcast + Rain + clouddens = 9 + if temperature > 5 then + precepitation = 1 -- rain + else + precepitation = 3 -- snow + end + elseif cloudspreset:find( "RainyPreset3" ) then + -- Overcast + Rain + clouddens = 9 + if temperature > 5 then + precepitation = 1 -- rain + else + precepitation = 3 -- snow end end - - local CLOUDBASE=string.format("%d", UTILS.MetersToFeet(cloudbase)) - local CLOUDCEIL=string.format("%d", UTILS.MetersToFeet(cloudceil)) + + local CLOUDBASE = string.format( "%d", UTILS.MetersToFeet( cloudbase ) ) + local CLOUDCEIL = string.format( "%d", UTILS.MetersToFeet( cloudceil ) ) if self.metric then - CLOUDBASE=string.format("%d", cloudbase) - CLOUDCEIL=string.format("%d", cloudceil) + CLOUDBASE = string.format( "%d", cloudbase ) + CLOUDCEIL = string.format( "%d", cloudceil ) end -- Cloud base/ceiling in thousands and hundrets of ft/meters. - local CLOUDBASE1000, CLOUDBASE0100=self:_GetThousandsAndHundreds(UTILS.MetersToFeet(cloudbase)) - local CLOUDCEIL1000, CLOUDCEIL0100=self:_GetThousandsAndHundreds(UTILS.MetersToFeet(cloudceil)) + local CLOUDBASE1000, CLOUDBASE0100 = self:_GetThousandsAndHundreds( UTILS.MetersToFeet( cloudbase ) ) + local CLOUDCEIL1000, CLOUDCEIL0100 = self:_GetThousandsAndHundreds( UTILS.MetersToFeet( cloudceil ) ) if self.metric then - CLOUDBASE1000, CLOUDBASE0100=self:_GetThousandsAndHundreds(cloudbase) - CLOUDCEIL1000, CLOUDCEIL0100=self:_GetThousandsAndHundreds(cloudceil) + CLOUDBASE1000, CLOUDBASE0100 = self:_GetThousandsAndHundreds( cloudbase ) + CLOUDCEIL1000, CLOUDCEIL0100 = self:_GetThousandsAndHundreds( cloudceil ) end -- No cloud info for dynamic weather. - local CloudCover={} --#ATIS.Soundfile - CloudCover=ATIS.Sound.CloudsNotAvailable - local CLOUDSsub="Cloud coverage information not available" + local CloudCover = {} -- #ATIS.Soundfile + CloudCover = ATIS.Sound.CloudsNotAvailable + local CLOUDSsub = "Cloud coverage information not available" -- Only valid for static weather. if static then - if clouddens>=9 then + if clouddens >= 9 then -- Overcast 9,10 - CloudCover=ATIS.Sound.CloudsOvercast - CLOUDSsub="Overcast" - elseif clouddens>=7 then + CloudCover = ATIS.Sound.CloudsOvercast + CLOUDSsub = "Overcast" + elseif clouddens >= 7 then -- Broken 7,8 - CloudCover=ATIS.Sound.CloudsBroken - CLOUDSsub="Broken clouds" - elseif clouddens>=4 then + CloudCover = ATIS.Sound.CloudsBroken + CLOUDSsub = "Broken clouds" + elseif clouddens >= 4 then -- Scattered 4,5,6 - CloudCover=ATIS.Sound.CloudsScattered - CLOUDSsub="Scattered clouds" - elseif clouddens>=1 then + CloudCover = ATIS.Sound.CloudsScattered + CLOUDSsub = "Scattered clouds" + elseif clouddens >= 1 then -- Few 1,2,3 - CloudCover=ATIS.Sound.CloudsFew - CLOUDSsub="Few clouds" + CloudCover = ATIS.Sound.CloudsFew + CLOUDSsub = "Few clouds" else -- No clouds - CLOUDBASE=nil - CLOUDCEIL=nil - CloudCover=ATIS.Sound.CloudsNo - CLOUDSsub="No clouds" + CLOUDBASE = nil + CLOUDCEIL = nil + CloudCover = ATIS.Sound.CloudsNo + CLOUDSsub = "No clouds" end end @@ -1704,558 +1689,558 @@ function ATIS:onafterBroadcast(From, Event, To) -------------------- -- Subtitle - local subtitle="" + local subtitle = "" - --Airbase name - subtitle=string.format("%s", self.airbasename) - if self.airbasename:find("AFB")==nil and self.airbasename:find("Airport")==nil and self.airbasename:find("Airstrip")==nil and self.airbasename:find("airfield")==nil and self.airbasename:find("AB")==nil then - subtitle=subtitle.." Airport" + -- Airbase name + subtitle = string.format( "%s", self.airbasename ) + if self.airbasename:find( "AFB" ) == nil and self.airbasename:find( "Airport" ) == nil and self.airbasename:find( "Airstrip" ) == nil and self.airbasename:find( "airfield" ) == nil and self.airbasename:find( "AB" ) == nil then + subtitle = subtitle .. " Airport" end if not self.useSRS then - self.radioqueue:NewTransmission(string.format("%s/%s.ogg", self.theatre, self.airbasename), 3.0, self.soundpath, nil, nil, subtitle, self.subduration) + self.radioqueue:NewTransmission( string.format( "%s/%s.ogg", self.theatre, self.airbasename ), 3.0, self.soundpath, nil, nil, subtitle, self.subduration ) end - local alltext=subtitle + local alltext = subtitle -- Information tag - subtitle=string.format("Information %s", NATO) - local _INFORMATION=subtitle + subtitle = string.format( "Information %s", NATO ) + local _INFORMATION = subtitle if not self.useSRS then - self:Transmission(ATIS.Sound.Information, 0.5, subtitle) - self.radioqueue:NewTransmission(string.format("NATO Alphabet/%s.ogg", NATO), 0.75, self.soundpath) + self:Transmission( ATIS.Sound.Information, 0.5, subtitle ) + self.radioqueue:NewTransmission( string.format( "NATO Alphabet/%s.ogg", NATO ), 0.75, self.soundpath ) end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle -- Zulu Time - subtitle=string.format("%s Zulu", ZULU) + subtitle = string.format( "%s Zulu", ZULU ) if not self.useSRS then - self.radioqueue:Number2Transmission(ZULU, nil, 0.5) - self:Transmission(ATIS.Sound.Zulu, 0.2, subtitle) + self.radioqueue:Number2Transmission( ZULU, nil, 0.5 ) + self:Transmission( ATIS.Sound.Zulu, 0.2, subtitle ) end - alltext=alltext..";\n"..subtitle - + alltext = alltext .. ";\n" .. subtitle + if not self.zulutimeonly then -- Sunrise Time - subtitle=string.format("Sunrise at %s local time", SUNRISE) + subtitle = string.format( "Sunrise at %s local time", SUNRISE ) if not self.useSRS then - self:Transmission(ATIS.Sound.SunriseAt, 0.5, subtitle) - self.radioqueue:Number2Transmission(SUNRISE, nil, 0.2) - self:Transmission(ATIS.Sound.TimeLocal, 0.2) + self:Transmission( ATIS.Sound.SunriseAt, 0.5, subtitle ) + self.radioqueue:Number2Transmission( SUNRISE, nil, 0.2 ) + self:Transmission( ATIS.Sound.TimeLocal, 0.2 ) end - alltext=alltext..";\n"..subtitle - + alltext = alltext .. ";\n" .. subtitle + -- Sunset Time - subtitle=string.format("Sunset at %s local time", SUNSET) + subtitle = string.format( "Sunset at %s local time", SUNSET ) if not self.useSRS then - self:Transmission(ATIS.Sound.SunsetAt, 0.5, subtitle) - self.radioqueue:Number2Transmission(SUNSET, nil, 0.5) - self:Transmission(ATIS.Sound.TimeLocal, 0.2) + self:Transmission( ATIS.Sound.SunsetAt, 0.5, subtitle ) + self.radioqueue:Number2Transmission( SUNSET, nil, 0.5 ) + self:Transmission( ATIS.Sound.TimeLocal, 0.2 ) end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle end - + -- Wind if self.metric then - subtitle=string.format("Wind from %s at %s m/s", WINDFROM, WINDSPEED) + subtitle = string.format( "Wind from %s at %s m/s", WINDFROM, WINDSPEED ) else - subtitle=string.format("Wind from %s at %s knots", WINDFROM, WINDSPEED) + subtitle = string.format( "Wind from %s at %s knots", WINDFROM, WINDSPEED ) end - if turbulence>0 then - subtitle=subtitle..", gusting" + if turbulence > 0 then + subtitle = subtitle .. ", gusting" end - local _WIND=subtitle + local _WIND = subtitle if not self.useSRS then - self:Transmission(ATIS.Sound.WindFrom, 1.0, subtitle) - self.radioqueue:Number2Transmission(WINDFROM) - self:Transmission(ATIS.Sound.At, 0.2) - self.radioqueue:Number2Transmission(WINDSPEED) + self:Transmission( ATIS.Sound.WindFrom, 1.0, subtitle ) + self.radioqueue:Number2Transmission( WINDFROM ) + self:Transmission( ATIS.Sound.At, 0.2 ) + self.radioqueue:Number2Transmission( WINDSPEED ) if self.metric then - self:Transmission(ATIS.Sound.MetersPerSecond, 0.2) + self:Transmission( ATIS.Sound.MetersPerSecond, 0.2 ) else - self:Transmission(ATIS.Sound.Knots, 0.2) + self:Transmission( ATIS.Sound.Knots, 0.2 ) end - if turbulence>0 then - self:Transmission(ATIS.Sound.Gusting, 0.2) + if turbulence > 0 then + self:Transmission( ATIS.Sound.Gusting, 0.2 ) end end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle -- Visibility if self.metric then - subtitle=string.format("Visibility %s km", VISIBILITY) + subtitle = string.format( "Visibility %s km", VISIBILITY ) else - subtitle=string.format("Visibility %s SM", VISIBILITY) + subtitle = string.format( "Visibility %s SM", VISIBILITY ) end if not self.useSRS then - self:Transmission(ATIS.Sound.Visibilty, 1.0, subtitle) - self.radioqueue:Number2Transmission(VISIBILITY) + self:Transmission( ATIS.Sound.Visibilty, 1.0, subtitle ) + self.radioqueue:Number2Transmission( VISIBILITY ) if self.metric then - self:Transmission(ATIS.Sound.Kilometers, 0.2) + self:Transmission( ATIS.Sound.Kilometers, 0.2 ) else - self:Transmission(ATIS.Sound.StatuteMiles, 0.2) + self:Transmission( ATIS.Sound.StatuteMiles, 0.2 ) end end - alltext=alltext..";\n"..subtitle - + alltext = alltext .. ";\n" .. subtitle + -- Weather phenomena - local wp=false - local wpsub="" - if precepitation==1 then - wp=true - wpsub=wpsub.." rain" - elseif precepitation==2 then + local wp = false + local wpsub = "" + if precepitation == 1 then + wp = true + wpsub = wpsub .. " rain" + elseif precepitation == 2 then if wp then - wpsub=wpsub.."," + wpsub = wpsub .. "," end - wpsub=wpsub.." thunderstorm" - wp=true - elseif precepitation==3 then - wpsub=wpsub.." snow" - wp=true - elseif precepitation==4 then - wpsub=wpsub.." snowstorm" - wp=true + wpsub = wpsub .. " thunderstorm" + wp = true + elseif precepitation == 3 then + wpsub = wpsub .. " snow" + wp = true + elseif precepitation == 4 then + wpsub = wpsub .. " snowstorm" + wp = true end if fog then if wp then - wpsub=wpsub.."," + wpsub = wpsub .. "," end - wpsub=wpsub.." fog" - wp=true + wpsub = wpsub .. " fog" + wp = true end if dust then if wp then - wpsub=wpsub.."," + wpsub = wpsub .. "," end - wpsub=wpsub.." dust" - wp=true + wpsub = wpsub .. " dust" + wp = true end -- Actual output if wp then - subtitle=string.format("Weather phenomena:%s", wpsub) + subtitle = string.format( "Weather phenomena:%s", wpsub ) if not self.useSRS then - self:Transmission(ATIS.Sound.WeatherPhenomena, 1.0, subtitle) - if precepitation==1 then - self:Transmission(ATIS.Sound.Rain, 0.5) - elseif precepitation==2 then - self:Transmission(ATIS.Sound.ThunderStorm, 0.5) - elseif precepitation==3 then - self:Transmission(ATIS.Sound.Snow, 0.5) - elseif precepitation==4 then - self:Transmission(ATIS.Sound.SnowStorm, 0.5) + self:Transmission( ATIS.Sound.WeatherPhenomena, 1.0, subtitle ) + if precepitation == 1 then + self:Transmission( ATIS.Sound.Rain, 0.5 ) + elseif precepitation == 2 then + self:Transmission( ATIS.Sound.ThunderStorm, 0.5 ) + elseif precepitation == 3 then + self:Transmission( ATIS.Sound.Snow, 0.5 ) + elseif precepitation == 4 then + self:Transmission( ATIS.Sound.SnowStorm, 0.5 ) end if fog then - self:Transmission(ATIS.Sound.Fog, 0.5) + self:Transmission( ATIS.Sound.Fog, 0.5 ) end if dust then - self:Transmission(ATIS.Sound.Dust, 0.5) + self:Transmission( ATIS.Sound.Dust, 0.5 ) end end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle end -- Cloud base if not self.useSRS then - self:Transmission(CloudCover, 1.0, CLOUDSsub) + self:Transmission( CloudCover, 1.0, CLOUDSsub ) end if CLOUDBASE and static then -- Base - local cbase=tostring(tonumber(CLOUDBASE1000)*1000+tonumber(CLOUDBASE0100)*100) - local cceil=tostring(tonumber(CLOUDCEIL1000)*1000+tonumber(CLOUDCEIL0100)*100) + local cbase = tostring( tonumber( CLOUDBASE1000 ) * 1000 + tonumber( CLOUDBASE0100 ) * 100 ) + local cceil = tostring( tonumber( CLOUDCEIL1000 ) * 1000 + tonumber( CLOUDCEIL0100 ) * 100 ) if self.metric then - --subtitle=string.format("Cloud base %s, ceiling %s meters", CLOUDBASE, CLOUDCEIL) - subtitle=string.format("Cloud base %s, ceiling %s meters", cbase, cceil) + -- subtitle=string.format("Cloud base %s, ceiling %s meters", CLOUDBASE, CLOUDCEIL) + subtitle = string.format( "Cloud base %s, ceiling %s meters", cbase, cceil ) else - --subtitle=string.format("Cloud base %s, ceiling %s feet", CLOUDBASE, CLOUDCEIL) - subtitle=string.format("Cloud base %s, ceiling %s feet", cbase, cceil) + -- subtitle=string.format("Cloud base %s, ceiling %s feet", CLOUDBASE, CLOUDCEIL) + subtitle = string.format( "Cloud base %s, ceiling %s feet", cbase, cceil ) end if not self.useSRS then - self:Transmission(ATIS.Sound.CloudBase, 1.0, subtitle) - if tonumber(CLOUDBASE1000)>0 then - self.radioqueue:Number2Transmission(CLOUDBASE1000) - self:Transmission(ATIS.Sound.Thousand, 0.1) + self:Transmission( ATIS.Sound.CloudBase, 1.0, subtitle ) + if tonumber( CLOUDBASE1000 ) > 0 then + self.radioqueue:Number2Transmission( CLOUDBASE1000 ) + self:Transmission( ATIS.Sound.Thousand, 0.1 ) end - if tonumber(CLOUDBASE0100)>0 then - self.radioqueue:Number2Transmission(CLOUDBASE0100) - self:Transmission(ATIS.Sound.Hundred, 0.1) + if tonumber( CLOUDBASE0100 ) > 0 then + self.radioqueue:Number2Transmission( CLOUDBASE0100 ) + self:Transmission( ATIS.Sound.Hundred, 0.1 ) end -- Ceiling - self:Transmission(ATIS.Sound.CloudCeiling, 0.5) - if tonumber(CLOUDCEIL1000)>0 then - self.radioqueue:Number2Transmission(CLOUDCEIL1000) - self:Transmission(ATIS.Sound.Thousand, 0.1) + self:Transmission( ATIS.Sound.CloudCeiling, 0.5 ) + if tonumber( CLOUDCEIL1000 ) > 0 then + self.radioqueue:Number2Transmission( CLOUDCEIL1000 ) + self:Transmission( ATIS.Sound.Thousand, 0.1 ) end - if tonumber(CLOUDCEIL0100)>0 then - self.radioqueue:Number2Transmission(CLOUDCEIL0100) - self:Transmission(ATIS.Sound.Hundred, 0.1) + if tonumber( CLOUDCEIL0100 ) > 0 then + self.radioqueue:Number2Transmission( CLOUDCEIL0100 ) + self:Transmission( ATIS.Sound.Hundred, 0.1 ) end if self.metric then - self:Transmission(ATIS.Sound.Meters, 0.1) + self:Transmission( ATIS.Sound.Meters, 0.1 ) else - self:Transmission(ATIS.Sound.Feet, 0.1) + self:Transmission( ATIS.Sound.Feet, 0.1 ) end end end - alltext=alltext..";\n"..subtitle - + alltext = alltext .. ";\n" .. subtitle + -- Temperature if self.TDegF then - if temperature<0 then - subtitle=string.format("Temperature -%s °F", TEMPERATURE) + if temperature < 0 then + subtitle = string.format( "Temperature -%s °F", TEMPERATURE ) else - subtitle=string.format("Temperature %s °F", TEMPERATURE) + subtitle = string.format( "Temperature %s °F", TEMPERATURE ) end else - if temperature<0 then - subtitle=string.format("Temperature -%s °C", TEMPERATURE) + if temperature < 0 then + subtitle = string.format( "Temperature -%s °C", TEMPERATURE ) else - subtitle=string.format("Temperature %s °C", TEMPERATURE) + subtitle = string.format( "Temperature %s °C", TEMPERATURE ) end end - local _TEMPERATURE=subtitle + local _TEMPERATURE = subtitle if not self.useSRS then - self:Transmission(ATIS.Sound.Temperature, 1.0, subtitle) - if temperature<0 then - self:Transmission(ATIS.Sound.Minus, 0.2) + self:Transmission( ATIS.Sound.Temperature, 1.0, subtitle ) + if temperature < 0 then + self:Transmission( ATIS.Sound.Minus, 0.2 ) end - self.radioqueue:Number2Transmission(TEMPERATURE) + self.radioqueue:Number2Transmission( TEMPERATURE ) if self.TDegF then - self:Transmission(ATIS.Sound.DegreesFahrenheit, 0.2) + self:Transmission( ATIS.Sound.DegreesFahrenheit, 0.2 ) else - self:Transmission(ATIS.Sound.DegreesCelsius, 0.2) + self:Transmission( ATIS.Sound.DegreesCelsius, 0.2 ) end end - alltext=alltext..";\n"..subtitle - + alltext = alltext .. ";\n" .. subtitle + -- Dew point if self.TDegF then - if dewpoint<0 then - subtitle=string.format("Dew point -%s °F", DEWPOINT) + if dewpoint < 0 then + subtitle = string.format( "Dew point -%s °F", DEWPOINT ) else - subtitle=string.format("Dew point %s °F", DEWPOINT) + subtitle = string.format( "Dew point %s °F", DEWPOINT ) end else - if dewpoint<0 then - subtitle=string.format("Dew point -%s °C", DEWPOINT) + if dewpoint < 0 then + subtitle = string.format( "Dew point -%s °C", DEWPOINT ) else - subtitle=string.format("Dew point %s °C", DEWPOINT) + subtitle = string.format( "Dew point %s °C", DEWPOINT ) end end - local _DEWPOINT=subtitle + local _DEWPOINT = subtitle if not self.useSRS then - self:Transmission(ATIS.Sound.DewPoint, 1.0, subtitle) - if dewpoint<0 then - self:Transmission(ATIS.Sound.Minus, 0.2) + self:Transmission( ATIS.Sound.DewPoint, 1.0, subtitle ) + if dewpoint < 0 then + self:Transmission( ATIS.Sound.Minus, 0.2 ) end - self.radioqueue:Number2Transmission(DEWPOINT) + self.radioqueue:Number2Transmission( DEWPOINT ) if self.TDegF then - self:Transmission(ATIS.Sound.DegreesFahrenheit, 0.2) + self:Transmission( ATIS.Sound.DegreesFahrenheit, 0.2 ) else - self:Transmission(ATIS.Sound.DegreesCelsius, 0.2) + self:Transmission( ATIS.Sound.DegreesCelsius, 0.2 ) end end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle -- Altimeter QNH/QFE. if self.PmmHg then if self.qnhonly then - subtitle=string.format("Altimeter %s.%s mmHg", QNH[1], QNH[2]) + subtitle = string.format( "Altimeter %s.%s mmHg", QNH[1], QNH[2] ) else - subtitle=string.format("Altimeter: QNH %s.%s, QFE %s.%s mmHg", QNH[1], QNH[2], QFE[1], QFE[2]) + subtitle = string.format( "Altimeter: QNH %s.%s, QFE %s.%s mmHg", QNH[1], QNH[2], QFE[1], QFE[2] ) end else if self.metric then if self.qnhonly then - subtitle=string.format("Altimeter %s.%s hPa", QNH[1], QNH[2]) + subtitle = string.format( "Altimeter %s.%s hPa", QNH[1], QNH[2] ) else - subtitle=string.format("Altimeter: QNH %s.%s, QFE %s.%s hPa", QNH[1], QNH[2], QFE[1], QFE[2]) + subtitle = string.format( "Altimeter: QNH %s.%s, QFE %s.%s hPa", QNH[1], QNH[2], QFE[1], QFE[2] ) end else if self.qnhonly then - subtitle=string.format("Altimeter %s.%s inHg", QNH[1], QNH[2]) + subtitle = string.format( "Altimeter %s.%s inHg", QNH[1], QNH[2] ) else - subtitle=string.format("Altimeter: QNH %s.%s, QFE %s.%s inHg", QNH[1], QNH[2], QFE[1], QFE[2]) + subtitle = string.format( "Altimeter: QNH %s.%s, QFE %s.%s inHg", QNH[1], QNH[2], QFE[1], QFE[2] ) end end end - local _ALTIMETER=subtitle + local _ALTIMETER = subtitle if not self.useSRS then - self:Transmission(ATIS.Sound.Altimeter, 1.0, subtitle) + self:Transmission( ATIS.Sound.Altimeter, 1.0, subtitle ) if not self.qnhonly then - self:Transmission(ATIS.Sound.QNH, 0.5) + self:Transmission( ATIS.Sound.QNH, 0.5 ) end - self.radioqueue:Number2Transmission(QNH[1]) + self.radioqueue:Number2Transmission( QNH[1] ) if ATIS.ICAOPhraseology[UTILS.GetDCSMap()] then - self:Transmission(ATIS.Sound.Decimal, 0.2) + self:Transmission( ATIS.Sound.Decimal, 0.2 ) end - self.radioqueue:Number2Transmission(QNH[2]) - + self.radioqueue:Number2Transmission( QNH[2] ) + if not self.qnhonly then - self:Transmission(ATIS.Sound.QFE, 0.75) - self.radioqueue:Number2Transmission(QFE[1]) - if ATIS.ICAOPhraseology[UTILS.GetDCSMap()] then - self:Transmission(ATIS.Sound.Decimal, 0.2) - end - self.radioqueue:Number2Transmission(QFE[2]) - end - + self:Transmission( ATIS.Sound.QFE, 0.75 ) + self.radioqueue:Number2Transmission( QFE[1] ) + if ATIS.ICAOPhraseology[UTILS.GetDCSMap()] then + self:Transmission( ATIS.Sound.Decimal, 0.2 ) + end + self.radioqueue:Number2Transmission( QFE[2] ) + end + if self.PmmHg then - self:Transmission(ATIS.Sound.MillimetersOfMercury, 0.1) + self:Transmission( ATIS.Sound.MillimetersOfMercury, 0.1 ) else if self.metric then - self:Transmission(ATIS.Sound.HectoPascal, 0.1) + self:Transmission( ATIS.Sound.HectoPascal, 0.1 ) else - self:Transmission(ATIS.Sound.InchesOfMercury, 0.1) - end + self:Transmission( ATIS.Sound.InchesOfMercury, 0.1 ) + end end end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle -- Active runway. - local subtitle=string.format("Active runway %s", runway) - if rwyLeft==true then - subtitle=subtitle.." Left" - elseif rwyLeft==false then - subtitle=subtitle.." Right" + local subtitle = string.format( "Active runway %s", runway ) + if rwyLeft == true then + subtitle = subtitle .. " Left" + elseif rwyLeft == false then + subtitle = subtitle .. " Right" end - local _RUNACT=subtitle + local _RUNACT = subtitle if not self.useSRS then - self:Transmission(ATIS.Sound.ActiveRunway, 1.0, subtitle) - self.radioqueue:Number2Transmission(runway) - if rwyLeft==true then - self:Transmission(ATIS.Sound.Left, 0.2) - elseif rwyLeft==false then - self:Transmission(ATIS.Sound.Right, 0.2) + self:Transmission( ATIS.Sound.ActiveRunway, 1.0, subtitle ) + self.radioqueue:Number2Transmission( runway ) + if rwyLeft == true then + self:Transmission( ATIS.Sound.Left, 0.2 ) + elseif rwyLeft == false then + self:Transmission( ATIS.Sound.Right, 0.2 ) end end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle -- Runway length. if self.rwylength then - local runact=self.airbase:GetActiveRunway(self.runwaym2t) - local length=runact.length + local runact = self.airbase:GetActiveRunway( self.runwaym2t ) + local length = runact.length if not self.metric then - length=UTILS.MetersToFeet(length) + length = UTILS.MetersToFeet( length ) end -- Length in thousands and hundrets of ft/meters. - local L1000, L0100=self:_GetThousandsAndHundreds(length) + local L1000, L0100 = self:_GetThousandsAndHundreds( length ) -- Subtitle. - local subtitle=string.format("Runway length %d", length) + local subtitle = string.format( "Runway length %d", length ) if self.metric then - subtitle=subtitle.." meters" + subtitle = subtitle .. " meters" else - subtitle=subtitle.." feet" + subtitle = subtitle .. " feet" end -- Transmit. if not self.useSRS then - self:Transmission(ATIS.Sound.RunwayLength, 1.0, subtitle) - if tonumber(L1000)>0 then - self.radioqueue:Number2Transmission(L1000) - self:Transmission(ATIS.Sound.Thousand, 0.1) + self:Transmission( ATIS.Sound.RunwayLength, 1.0, subtitle ) + if tonumber( L1000 ) > 0 then + self.radioqueue:Number2Transmission( L1000 ) + self:Transmission( ATIS.Sound.Thousand, 0.1 ) end - if tonumber(L0100)>0 then - self.radioqueue:Number2Transmission(L0100) - self:Transmission(ATIS.Sound.Hundred, 0.1) + if tonumber( L0100 ) > 0 then + self.radioqueue:Number2Transmission( L0100 ) + self:Transmission( ATIS.Sound.Hundred, 0.1 ) end if self.metric then - self:Transmission(ATIS.Sound.Meters, 0.1) + self:Transmission( ATIS.Sound.Meters, 0.1 ) else - self:Transmission(ATIS.Sound.Feet, 0.1) + self:Transmission( ATIS.Sound.Feet, 0.1 ) end end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle end -- Airfield elevation if self.elevation then - local elevation=self.airbase:GetHeight() + local elevation = self.airbase:GetHeight() if not self.metric then - elevation=UTILS.MetersToFeet(elevation) + elevation = UTILS.MetersToFeet( elevation ) end -- Length in thousands and hundrets of ft/meters. - local L1000, L0100=self:_GetThousandsAndHundreds(elevation) + local L1000, L0100 = self:_GetThousandsAndHundreds( elevation ) -- Subtitle. - local subtitle=string.format("Elevation %d", elevation) + local subtitle = string.format( "Elevation %d", elevation ) if self.metric then - subtitle=subtitle.." meters" + subtitle = subtitle .. " meters" else - subtitle=subtitle.." feet" + subtitle = subtitle .. " feet" end -- Transmit. if not self.useSRS then - self:Transmission(ATIS.Sound.Elevation, 1.0, subtitle) - if tonumber(L1000)>0 then - self.radioqueue:Number2Transmission(L1000) - self:Transmission(ATIS.Sound.Thousand, 0.1) + self:Transmission( ATIS.Sound.Elevation, 1.0, subtitle ) + if tonumber( L1000 ) > 0 then + self.radioqueue:Number2Transmission( L1000 ) + self:Transmission( ATIS.Sound.Thousand, 0.1 ) end - if tonumber(L0100)>0 then - self.radioqueue:Number2Transmission(L0100) - self:Transmission(ATIS.Sound.Hundred, 0.1) + if tonumber( L0100 ) > 0 then + self.radioqueue:Number2Transmission( L0100 ) + self:Transmission( ATIS.Sound.Hundred, 0.1 ) end if self.metric then - self:Transmission(ATIS.Sound.Meters, 0.1) + self:Transmission( ATIS.Sound.Meters, 0.1 ) else - self:Transmission(ATIS.Sound.Feet, 0.1) + self:Transmission( ATIS.Sound.Feet, 0.1 ) end end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle end -- Tower frequency. if self.towerfrequency then - local freqs="" - for i,freq in pairs(self.towerfrequency) do - freqs=freqs..string.format("%.3f MHz", freq) - if i<#self.towerfrequency then - freqs=freqs..", " + local freqs = "" + for i, freq in pairs( self.towerfrequency ) do + freqs = freqs .. string.format( "%.3f MHz", freq ) + if i < #self.towerfrequency then + freqs = freqs .. ", " end end - subtitle=string.format("Tower frequency %s", freqs) + subtitle = string.format( "Tower frequency %s", freqs ) if not self.useSRS then - self:Transmission(ATIS.Sound.TowerFrequency, 1.0, subtitle) - for _,freq in pairs(self.towerfrequency) do - local f=string.format("%.3f", freq) - f=UTILS.Split(f, ".") - self.radioqueue:Number2Transmission(f[1], nil, 0.5) - if tonumber(f[2])>0 then - self:Transmission(ATIS.Sound.Decimal, 0.2) - self.radioqueue:Number2Transmission(f[2]) + self:Transmission( ATIS.Sound.TowerFrequency, 1.0, subtitle ) + for _, freq in pairs( self.towerfrequency ) do + local f = string.format( "%.3f", freq ) + f = UTILS.Split( f, "." ) + self.radioqueue:Number2Transmission( f[1], nil, 0.5 ) + if tonumber( f[2] ) > 0 then + self:Transmission( ATIS.Sound.Decimal, 0.2 ) + self.radioqueue:Number2Transmission( f[2] ) end - self:Transmission(ATIS.Sound.MegaHertz, 0.2) + self:Transmission( ATIS.Sound.MegaHertz, 0.2 ) end end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle end -- ILS - local ils=self:GetNavPoint(self.ils, runway, rwyLeft) + local ils = self:GetNavPoint( self.ils, runway, rwyLeft ) if ils then - subtitle=string.format("ILS frequency %.2f MHz", ils.frequency) - if not self.useSRS then - self:Transmission(ATIS.Sound.ILSFrequency, 1.0, subtitle) - local f=string.format("%.2f", ils.frequency) - f=UTILS.Split(f, ".") - self.radioqueue:Number2Transmission(f[1], nil, 0.5) - if tonumber(f[2])>0 then - self:Transmission(ATIS.Sound.Decimal, 0.2) - self.radioqueue:Number2Transmission(f[2]) + subtitle = string.format( "ILS frequency %.2f MHz", ils.frequency ) + if not self.useSRS then + self:Transmission( ATIS.Sound.ILSFrequency, 1.0, subtitle ) + local f = string.format( "%.2f", ils.frequency ) + f = UTILS.Split( f, "." ) + self.radioqueue:Number2Transmission( f[1], nil, 0.5 ) + if tonumber( f[2] ) > 0 then + self:Transmission( ATIS.Sound.Decimal, 0.2 ) + self.radioqueue:Number2Transmission( f[2] ) end - self:Transmission(ATIS.Sound.MegaHertz, 0.2) - end - alltext=alltext..";\n"..subtitle + self:Transmission( ATIS.Sound.MegaHertz, 0.2 ) + end + alltext = alltext .. ";\n" .. subtitle end -- Outer NDB - local ndb=self:GetNavPoint(self.ndbouter, runway, rwyLeft) + local ndb = self:GetNavPoint( self.ndbouter, runway, rwyLeft ) if ndb then - subtitle=string.format("Outer NDB frequency %.2f MHz", ndb.frequency) + subtitle = string.format( "Outer NDB frequency %.2f MHz", ndb.frequency ) if not self.useSRS then - self:Transmission(ATIS.Sound.OuterNDBFrequency, 1.0, subtitle) - local f=string.format("%.2f", ndb.frequency) - f=UTILS.Split(f, ".") - self.radioqueue:Number2Transmission(f[1], nil, 0.5) - if tonumber(f[2])>0 then - self:Transmission(ATIS.Sound.Decimal, 0.2) - self.radioqueue:Number2Transmission(f[2]) + self:Transmission( ATIS.Sound.OuterNDBFrequency, 1.0, subtitle ) + local f = string.format( "%.2f", ndb.frequency ) + f = UTILS.Split( f, "." ) + self.radioqueue:Number2Transmission( f[1], nil, 0.5 ) + if tonumber( f[2] ) > 0 then + self:Transmission( ATIS.Sound.Decimal, 0.2 ) + self.radioqueue:Number2Transmission( f[2] ) end - self:Transmission(ATIS.Sound.MegaHertz, 0.2) + self:Transmission( ATIS.Sound.MegaHertz, 0.2 ) end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle end -- Inner NDB - local ndb=self:GetNavPoint(self.ndbinner, runway, rwyLeft) + local ndb = self:GetNavPoint( self.ndbinner, runway, rwyLeft ) if ndb then - subtitle=string.format("Inner NDB frequency %.2f MHz", ndb.frequency) + subtitle = string.format( "Inner NDB frequency %.2f MHz", ndb.frequency ) if not self.useSRS then - self:Transmission(ATIS.Sound.InnerNDBFrequency, 1.0, subtitle) - local f=string.format("%.2f", ndb.frequency) - f=UTILS.Split(f, ".") - self.radioqueue:Number2Transmission(f[1], nil, 0.5) - if tonumber(f[2])>0 then - self:Transmission(ATIS.Sound.Decimal, 0.2) - self.radioqueue:Number2Transmission(f[2]) + self:Transmission( ATIS.Sound.InnerNDBFrequency, 1.0, subtitle ) + local f = string.format( "%.2f", ndb.frequency ) + f = UTILS.Split( f, "." ) + self.radioqueue:Number2Transmission( f[1], nil, 0.5 ) + if tonumber( f[2] ) > 0 then + self:Transmission( ATIS.Sound.Decimal, 0.2 ) + self.radioqueue:Number2Transmission( f[2] ) end - self:Transmission(ATIS.Sound.MegaHertz, 0.2) - end - alltext=alltext..";\n"..subtitle + self:Transmission( ATIS.Sound.MegaHertz, 0.2 ) + end + alltext = alltext .. ";\n" .. subtitle end -- VOR if self.vor then - subtitle=string.format("VOR frequency %.2f MHz", self.vor) + subtitle = string.format( "VOR frequency %.2f MHz", self.vor ) if self.useSRS then - subtitle=string.format("V O R frequency %.2f MHz", self.vor) + subtitle = string.format( "V O R frequency %.2f MHz", self.vor ) end if not self.useSRS then - self:Transmission(ATIS.Sound.VORFrequency, 1.0, subtitle) - local f=string.format("%.2f", self.vor) - f=UTILS.Split(f, ".") - self.radioqueue:Number2Transmission(f[1], nil, 0.5) - if tonumber(f[2])>0 then - self:Transmission(ATIS.Sound.Decimal, 0.2) - self.radioqueue:Number2Transmission(f[2]) + self:Transmission( ATIS.Sound.VORFrequency, 1.0, subtitle ) + local f = string.format( "%.2f", self.vor ) + f = UTILS.Split( f, "." ) + self.radioqueue:Number2Transmission( f[1], nil, 0.5 ) + if tonumber( f[2] ) > 0 then + self:Transmission( ATIS.Sound.Decimal, 0.2 ) + self.radioqueue:Number2Transmission( f[2] ) end - self:Transmission(ATIS.Sound.MegaHertz, 0.2) + self:Transmission( ATIS.Sound.MegaHertz, 0.2 ) end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle end -- TACAN if self.tacan then - subtitle=string.format("TACAN channel %dX", self.tacan) + subtitle = string.format( "TACAN channel %dX", self.tacan ) if not self.useSRS then - self:Transmission(ATIS.Sound.TACANChannel, 1.0, subtitle) - self.radioqueue:Number2Transmission(tostring(self.tacan), nil, 0.2) - self.radioqueue:NewTransmission("NATO Alphabet/Xray.ogg", 0.75, self.soundpath, nil, 0.2) + self:Transmission( ATIS.Sound.TACANChannel, 1.0, subtitle ) + self.radioqueue:Number2Transmission( tostring( self.tacan ), nil, 0.2 ) + self.radioqueue:NewTransmission( "NATO Alphabet/Xray.ogg", 0.75, self.soundpath, nil, 0.2 ) end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle end -- RSBN if self.rsbn then - subtitle=string.format("RSBN channel %d", self.rsbn) + subtitle = string.format( "RSBN channel %d", self.rsbn ) if not self.useSRS then - self:Transmission(ATIS.Sound.RSBNChannel, 1.0, subtitle) - self.radioqueue:Number2Transmission(tostring(self.rsbn), nil, 0.2) + self:Transmission( ATIS.Sound.RSBNChannel, 1.0, subtitle ) + self.radioqueue:Number2Transmission( tostring( self.rsbn ), nil, 0.2 ) end - alltext=alltext..";\n"..subtitle + alltext = alltext .. ";\n" .. subtitle end -- PRMG - local ndb=self:GetNavPoint(self.prmg, runway, rwyLeft) + local ndb = self:GetNavPoint( self.prmg, runway, rwyLeft ) if ndb then - subtitle=string.format("PRMG channel %d", ndb.frequency) + subtitle = string.format( "PRMG channel %d", ndb.frequency ) if not self.useSRS then - self:Transmission(ATIS.Sound.PRMGChannel, 1.0, subtitle) - self.radioqueue:Number2Transmission(tostring(ndb.frequency), nil, 0.5) - end - alltext=alltext..";\n"..subtitle + self:Transmission( ATIS.Sound.PRMGChannel, 1.0, subtitle ) + self.radioqueue:Number2Transmission( tostring( ndb.frequency ), nil, 0.5 ) + end + alltext = alltext .. ";\n" .. subtitle end - + -- Advice on initial... - subtitle=string.format("Advise on initial contact, you have information %s", NATO) + subtitle = string.format( "Advise on initial contact, you have information %s", NATO ) if not self.useSRS then - self:Transmission(ATIS.Sound.AdviceOnInitial, 0.5, subtitle) - self.radioqueue:NewTransmission(string.format("NATO Alphabet/%s.ogg", NATO), 0.75, self.soundpath) - end - alltext=alltext..";\n"..subtitle - + self:Transmission( ATIS.Sound.AdviceOnInitial, 0.5, subtitle ) + self.radioqueue:NewTransmission( string.format( "NATO Alphabet/%s.ogg", NATO ), 0.75, self.soundpath ) + end + alltext = alltext .. ";\n" .. subtitle + -- Report ATIS text. - self:Report(alltext) + self:Report( alltext ) -- Update F10 marker. if self.usemarker then - self:UpdateMarker(_INFORMATION, _RUNACT, _WIND, _ALTIMETER, _TEMPERATURE) + self:UpdateMarker( _INFORMATION, _RUNACT, _WIND, _ALTIMETER, _TEMPERATURE ) end end @@ -2266,34 +2251,34 @@ end -- @param #string Event Event. -- @param #string To To state. -- @param #string Text Report text. -function ATIS:onafterReport(From, Event, To, Text) - self:T(self.lid..string.format("Report:\n%s", Text)) - +function ATIS:onafterReport( From, Event, To, Text ) + self:T( self.lid .. string.format( "Report:\n%s", Text ) ) + if self.useSRS and self.msrs then - + -- Remove line breaks - local text=string.gsub(Text, "[\r\n]", "") - + local text = string.gsub( Text, "[\r\n]", "" ) + -- Replace other stuff. - local text=string.gsub(text, "SM", "statute miles") - local text=string.gsub(text, "°C", "degrees Celsius") - local text=string.gsub(text, "°F", "degrees Fahrenheit") - local text=string.gsub(text, "inHg", "inches of Mercury") - local text=string.gsub(text, "mmHg", "millimeters of Mercury") - local text=string.gsub(text, "hPa", "hectopascals") - local text=string.gsub(text, "m/s", "meters per second") - + local text = string.gsub( text, "SM", "statute miles" ) + local text = string.gsub( text, "°C", "degrees Celsius" ) + local text = string.gsub( text, "°F", "degrees Fahrenheit" ) + local text = string.gsub( text, "inHg", "inches of Mercury" ) + local text = string.gsub( text, "mmHg", "millimeters of Mercury" ) + local text = string.gsub( text, "hPa", "hectopascals" ) + local text = string.gsub( text, "m/s", "meters per second" ) + -- Replace ";" by "." - local text=string.gsub(text, ";", " . ") - - --Debug output. - self:T("SRS TTS: "..text) - + local text = string.gsub( text, ";", " . " ) + + -- Debug output. + self:T( "SRS TTS: " .. text ) + -- Play text-to-speech report. - self.msrs:PlayText(text) - + self.msrs:PlayText( text ) + end - + end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -2303,25 +2288,25 @@ end --- Base captured -- @param #ATIS self -- @param Core.Event#EVENTDATA EventData Event data. -function ATIS:OnEventBaseCaptured(EventData) - +function ATIS:OnEventBaseCaptured( EventData ) + if EventData and EventData.Place then -- Place is the airbase that was captured. - local airbase=EventData.Place --Wrapper.Airbase#AIRBASE + local airbase = EventData.Place -- Wrapper.Airbase#AIRBASE -- Check that this airbase belongs or did belong to this warehouse. - if EventData.PlaceName==self.airbasename then + if EventData.PlaceName == self.airbasename then -- New coalition of airbase after it was captured. - local NewCoalitionAirbase=airbase:GetCoalition() - - if self.useSRS and self.msrs and self.msrs.coalition~=NewCoalitionAirbase then - self.msrs:SetCoalition(NewCoalitionAirbase) + local NewCoalitionAirbase = airbase:GetCoalition() + + if self.useSRS and self.msrs and self.msrs.coalition ~= NewCoalitionAirbase then + self.msrs:SetCoalition( NewCoalitionAirbase ) end - + end - + end end @@ -2338,21 +2323,21 @@ end -- @param #string altimeter Altimeter text. -- @param #string temperature Temperature text. -- @return #number Marker ID. -function ATIS:UpdateMarker(information, runact, wind, altimeter, temperature) +function ATIS:UpdateMarker( information, runact, wind, altimeter, temperature ) if self.markerid then - self.airbase:GetCoordinate():RemoveMark(self.markerid) + self.airbase:GetCoordinate():RemoveMark( self.markerid ) end - local text=string.format("ATIS on %.3f %s, %s:\n", self.frequency, UTILS.GetModulationName(self.modulation), tostring(information)) - text=text..string.format("%s\n", tostring(runact)) - text=text..string.format("%s\n", tostring(wind)) - text=text..string.format("%s\n", tostring(altimeter)) - text=text..string.format("%s", tostring(temperature)) + local text = string.format( "ATIS on %.3f %s, %s:\n", self.frequency, UTILS.GetModulationName( self.modulation ), tostring( information ) ) + text = text .. string.format( "%s\n", tostring( runact ) ) + text = text .. string.format( "%s\n", tostring( wind ) ) + text = text .. string.format( "%s\n", tostring( altimeter ) ) + text = text .. string.format( "%s", tostring( temperature ) ) -- More info is not displayed on the marker! -- Place new mark - self.markerid=self.airbase:GetCoordinate():MarkToAll(text, true) + self.markerid = self.airbase:GetCoordinate():MarkToAll( text, true ) return self.markerid end @@ -2363,32 +2348,32 @@ end -- @return #boolean Use Left=true, Right=false, or nil. function ATIS:GetActiveRunway() - local coord=self.airbase:GetCoordinate() - local height=coord:GetLandHeight() + local coord = self.airbase:GetCoordinate() + local height = coord:GetLandHeight() -- Get wind direction and speed in m/s. - local windFrom, windSpeed=coord:GetWind(height+10) + local windFrom, windSpeed = coord:GetWind( height + 10 ) -- Get active runway data based on wind direction. - local runact=self.airbase:GetActiveRunway(self.runwaym2t) + local runact = self.airbase:GetActiveRunway( self.runwaym2t ) -- Active runway "31". - local runway=self:GetMagneticRunway(windFrom) or runact.idx + local runway = self:GetMagneticRunway( windFrom ) or runact.idx -- Left or right in case there are two runways with the same heading. - local rwyLeft=nil + local rwyLeft = nil -- Check if user explicitly specified a runway. if self.activerunway then -- Get explicit runway heading if specified. - local runwayno=self:GetRunwayWithoutLR(self.activerunway) - if runwayno~="" then - runway=runwayno + local runwayno = self:GetRunwayWithoutLR( self.activerunway ) + if runwayno ~= "" then + runway = runwayno end -- Was "L"eft or "R"ight given? - rwyLeft=self:GetRunwayLR(self.activerunway) + rwyLeft = self:GetRunwayLR( self.activerunway ) end return runway, rwyLeft @@ -2398,18 +2383,18 @@ end -- @param #ATIS self -- @param #number windfrom Wind direction (from) in degrees. -- @return #string Runway magnetic heading divided by ten (and rounded). Eg, "13" for 130°. -function ATIS:GetMagneticRunway(windfrom) +function ATIS:GetMagneticRunway( windfrom ) - local diffmin=nil - local runway=nil - for _,heading in pairs(self.runwaymag) do + local diffmin = nil + local runway = nil + for _, heading in pairs( self.runwaymag ) do - local hdg=self:GetRunwayWithoutLR(heading) + local hdg = self:GetRunwayWithoutLR( heading ) - local diff=UTILS.HdgDiff(windfrom, tonumber(hdg)*10) - if diffmin==nil or diff data is valid for all runways. return nav else - local navy=tonumber(self:GetRunwayWithoutLR(nav.runway))*10 - local rwyy=tonumber(self:GetRunwayWithoutLR(runway))*10 + local navy = tonumber( self:GetRunwayWithoutLR( nav.runway ) ) * 10 + local rwyy = tonumber( self:GetRunwayWithoutLR( runway ) ) * 10 - local navL=self:GetRunwayLR(nav.runway) - local hdgD=UTILS.HdgDiff(navy,rwyy) + local navL = self:GetRunwayLR( nav.runway ) + local hdgD = UTILS.HdgDiff( navy, rwyy ) - if hdgD<=15 then --We allow an error of +-15° here. - if navL==nil or (navL==true and left==true) or (navL==false and left==false) then + if hdgD <= 15 then -- We allow an error of +-15° here. + if navL == nil or (navL == true and left == true) or (navL == false and left == false) then return nav end end @@ -2455,9 +2440,9 @@ end -- @param #ATIS self -- @param #string runway Runway heading, *e.g.* "31L". -- @return #string Runway heading without left or right, *e.g.* "31". -function ATIS:GetRunwayWithoutLR(runway) - local rwywo=runway:gsub("%D+", "") - --self:I(string.format("FF runway=%s ==> rwywo=%s", runway, rwywo)) +function ATIS:GetRunwayWithoutLR( runway ) + local rwywo = runway:gsub( "%D+", "" ) + -- self:I(string.format("FF runway=%s ==> rwywo=%s", runway, rwywo)) return rwywo end @@ -2465,11 +2450,11 @@ end -- @param #ATIS self -- @param #string runway Runway heading, *e.g.* "31L". -- @return #boolean If *true*, left runway is active. If *false*, right runway. If *nil*, neither applies. -function ATIS:GetRunwayLR(runway) +function ATIS:GetRunwayLR( runway ) -- Get left/right if specified. - local rwyL=runway:lower():find("l") - local rwyR=runway:lower():find("r") + local rwyL = runway:lower():find( "l" ) + local rwyR = runway:lower():find( "r" ) if rwyL then return true @@ -2487,19 +2472,19 @@ end -- @param #number interval Interval in seconds after the last transmission finished. -- @param #string subtitle Subtitle of the transmission. -- @param #string path Path to sound file. Default self.soundpath. -function ATIS:Transmission(sound, interval, subtitle, path) - self.radioqueue:NewTransmission(sound.filename, sound.duration, path or self.soundpath, nil, interval, subtitle, self.subduration) +function ATIS:Transmission( sound, interval, subtitle, path ) + self.radioqueue:NewTransmission( sound.filename, sound.duration, path or self.soundpath, nil, interval, subtitle, self.subduration ) end --- Play all audio files. -- @param #ATIS self function ATIS:SoundCheck() - for _,_sound in pairs(ATIS.Sound) do - local sound=_sound --#ATIS.Soundfile - local subtitle=string.format("Playing sound file %s, duration %.2f sec", sound.filename, sound.duration) - self:Transmission(sound, nil, subtitle) - MESSAGE:New(subtitle, 5, "ATIS"):ToAll() + for _, _sound in pairs( ATIS.Sound ) do + local sound = _sound -- #ATIS.Soundfile + local subtitle = string.format( "Playing sound file %s, duration %.2f sec", sound.filename, sound.duration ) + self:Transmission( sound, nil, subtitle ) + MESSAGE:New( subtitle, 5, "ATIS" ):ToAll() end end @@ -2515,7 +2500,7 @@ end function ATIS:GetMissionWeather() -- Weather data from mission file. - local weather=env.mission.weather + local weather = env.mission.weather -- Clouds --[[ @@ -2527,25 +2512,25 @@ function ATIS:GetMissionWeather() ["iprecptns"] = 1, }, -- end of ["clouds"] ]] - local clouds=weather.clouds + local clouds = weather.clouds -- 0=static, 1=dynamic - local static=weather.atmosphere_type==0 + local static = weather.atmosphere_type == 0 -- Visibilty distance in meters. - local visibility=weather.visibility.distance + local visibility = weather.visibility.distance -- Ground turbulence. - local turbulence=weather.groundTurbulence + local turbulence = weather.groundTurbulence -- Dust --[[ ["enable_dust"] = false, ["dust_density"] = 0, ]] - local dust=nil - if weather.enable_dust==true then - dust=weather.dust_density + local dust = nil + if weather.enable_dust == true then + dust = weather.dust_density end -- Fog @@ -2557,35 +2542,34 @@ function ATIS:GetMissionWeather() ["visibility"] = 25, }, -- end of ["fog"] ]] - local fog=nil - if weather.enable_fog==true then - fog=weather.fog + local fog = nil + if weather.enable_fog == true then + fog = weather.fog end - self:T("FF weather:") - self:T({clouds=clouds}) - self:T({visibility=visibility}) - self:T({turbulence=turbulence}) - self:T({fog=fog}) - self:T({dust=dust}) - self:T({static=static}) + self:T( "FF weather:" ) + self:T( { clouds = clouds } ) + self:T( { visibility = visibility } ) + self:T( { turbulence = turbulence } ) + self:T( { fog = fog } ) + self:T( { dust = dust } ) + self:T( { static = static } ) return clouds, visibility, turbulence, fog, dust, static end - --- Get thousands of a number. -- @param #ATIS self -- @param #number n Number, *e.g.* 4359. -- @return #string Thousands of n, *e.g.* "4" for 4359. -- @return #string Hundreds of n, *e.g.* "4" for 4359 because its rounded. -function ATIS:_GetThousandsAndHundreds(n) +function ATIS:_GetThousandsAndHundreds( n ) - local N=UTILS.Round(n/1000, 1) + local N = UTILS.Round( n / 1000, 1 ) - local S=UTILS.Split(string.format("%.1f", N), ".") + local S = UTILS.Split( string.format( "%.1f", N ), "." ) - local t=S[1] - local h=S[2] + local t = S[1] + local h = S[2] return t, h end diff --git a/Moose Development/Moose/Ops/Airboss.lua b/Moose Development/Moose/Ops/Airboss.lua index 515dd4ca7..eee1ea3db 100644 --- a/Moose Development/Moose/Ops/Airboss.lua +++ b/Moose Development/Moose/Ops/Airboss.lua @@ -303,7 +303,6 @@ -- The AV-8B Harrier pattern is very similar, the only differences are as there is no angled deck there is no wake check. from the ninety you wil fly a straight approach offset 26 ft to port (left) of the tram line. -- The aim is to arrive abeam the landing spot in a stable hover at 120 ft with forward speed matched to the boat. From there the LSO will call "cleared to land". You then level cross to the tram line at the designated landing spot at land vertcally. When you stabalise over the landing spot LSO will call Stabalise to indicate you are centered at the correct spot. -- --- -- ## CASE III -- -- ![Banner Image](..\Presentations\AIRBOSS\Airboss_Case3.png) @@ -958,8 +957,6 @@ -- -- Again, changing the file name, subtitle, subtitle duration is not required if you name the file exactly like the original one, which is this case would be "LSO-RogerBall.ogg". -- --- --- -- ## The Radio Dilemma -- -- DCS offers two (actually three) ways to send radio messages. Each one has its advantages and disadvantages and it is important to understand the differences. @@ -1304,19 +1301,19 @@ AIRBOSS.AircraftCarrier={ -- @field #string JCARLOS Juan Carlos I (L61) [V/STOL Carrier] -- @field #string HMAS Canberra (L02) [V/STOL Carrier] -- @field #string KUZNETSOV Admiral Kuznetsov (CV 1143.5) -AIRBOSS.CarrierType={ - ROOSEVELT="CVN_71", - LINCOLN="CVN_72", - WASHINGTON="CVN_73", - TRUMAN="CVN_75", - STENNIS="Stennis", - FORRESTAL="Forrestal", - VINSON="VINSON", - TARAWA="LHA_Tarawa", - AMERICA="USS America LHA-6", - JCARLOS="L61", - CANBERRA="L02", - KUZNETSOV="KUZNECOW", +AIRBOSS.CarrierType = { + ROOSEVELT = "CVN_71", + LINCOLN = "CVN_72", + WASHINGTON = "CVN_73", + TRUMAN = "CVN_75", + STENNIS = "Stennis", + FORRESTAL = "Forrestal", + VINSON = "VINSON", + TARAWA = "LHA_Tarawa", + AMERICA = "USS America LHA-6", + JCARLOS = "L61", + CANBERRA = "L02", + KUZNETSOV = "KUZNECOW", } --- Carrier specific parameters. @@ -1396,36 +1393,36 @@ AIRBOSS.CarrierType={ -- @field #string BOLTER "Bolter Pattern". -- @field #string EMERGENCY "Emergency Landing". -- @field #string DEBRIEF "Debrief". -AIRBOSS.PatternStep={ - UNDEFINED="Undefined", - REFUELING="Refueling", - SPINNING="Spinning", - COMMENCING="Commencing", - HOLDING="Holding", - WAITING="Waiting for free Marshal stack", - PLATFORM="Platform", - ARCIN="Arc Turn In", - ARCOUT="Arc Turn Out", - DIRTYUP="Dirty Up", - BULLSEYE="Bullseye", - INITIAL="Initial", - BREAKENTRY="Break Entry", - EARLYBREAK="Early Break", - LATEBREAK="Late Break", - ABEAM="Abeam", - NINETY="Ninety", - WAKE="Wake", - FINAL="Turn Final", - GROOVE_XX="Groove X", - GROOVE_IM="Groove In the Middle", - GROOVE_IC="Groove In Close", - GROOVE_AR="Groove At the Ramp", - GROOVE_IW="Groove In the Wires", - GROOVE_AL="Groove Abeam Landing Spot", - GROOVE_LC="Groove Level Cross", - BOLTER="Bolter Pattern", - EMERGENCY="Emergency Landing", - DEBRIEF="Debrief", +AIRBOSS.PatternStep = { + UNDEFINED = "Undefined", + REFUELING = "Refueling", + SPINNING = "Spinning", + COMMENCING = "Commencing", + HOLDING = "Holding", + WAITING = "Waiting for free Marshal stack", + PLATFORM = "Platform", + ARCIN = "Arc Turn In", + ARCOUT = "Arc Turn Out", + DIRTYUP = "Dirty Up", + BULLSEYE = "Bullseye", + INITIAL = "Initial", + BREAKENTRY = "Break Entry", + EARLYBREAK = "Early Break", + LATEBREAK = "Late Break", + ABEAM = "Abeam", + NINETY = "Ninety", + WAKE = "Wake", + FINAL = "Turn Final", + GROOVE_XX = "Groove X", + GROOVE_IM = "Groove In the Middle", + GROOVE_IC = "Groove In Close", + GROOVE_AR = "Groove At the Ramp", + GROOVE_IW = "Groove In the Wires", + GROOVE_AL = "Groove Abeam Landing Spot", + GROOVE_LC = "Groove Level Cross", + BOLTER = "Bolter Pattern", + EMERGENCY = "Emergency Landing", + DEBRIEF = "Debrief", } --- Groove position. @@ -1438,15 +1435,15 @@ AIRBOSS.PatternStep={ -- @field #string AL "AL": Abeam landing position (V/STOL). -- @field #string LC "LC": Level crossing (V/STOL). -- @field #string IW "IW": In the wires. -AIRBOSS.GroovePos={ - X0="X0", - XX="XX", - IM="IM", - IC="IC", - AR="AR", - AL="AL", - LC="LC", - IW="IW", +AIRBOSS.GroovePos = { + X0 = "X0", + XX = "XX", + IM = "IM", + IC = "IC", + AR = "AR", + AL = "AL", + LC = "LC", + IW = "IW", } --- Radio. @@ -1581,10 +1578,10 @@ AIRBOSS.GroovePos={ -- @field #string EASY Flight Student. Shows tips and hints in important phases of the approach. -- @field #string NORMAL Naval aviator. Moderate number of hints but not really zip lip. -- @field #string HARD TOPGUN graduate. For people who know what they are doing. Nearly *ziplip*. -AIRBOSS.Difficulty={ - EASY="Flight Student", - NORMAL="Naval Aviator", - HARD="TOPGUN Graduate", +AIRBOSS.Difficulty = { + EASY = "Flight Student", + NORMAL = "Naval Aviator", + HARD = "TOPGUN Graduate", } --- Recovery window parameters. diff --git a/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua b/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua index d3b67cbff..12f0446a7 100644 --- a/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua +++ b/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua @@ -82,7 +82,7 @@ do -- TASK_A2A_DISPATCHER -- to pick up enemy aircraft as they approach so that CAP and GCI flights can be tasked to intercept them. -- -- ![Banner Image](..\Presentations\TASK_A2A_DISPATCHER\Dia7.JPG) - -- + -- -- Additionally in a hot war situation where the border is no longer respected the placement of radars has a big effect on how fast the war escalates. -- For example if they are a long way forward and can detect enemy planes on the ground and taking off -- they will start to vector CAP and GCI flights to attack them straight away which will immediately draw a response from the other coalition. @@ -182,7 +182,7 @@ do -- TASK_A2A_DISPATCHER Mission = nil, Detection = nil, Tasks = {}, - SweepZones = {} + SweepZones = {}, } --- TASK_A2A_DISPATCHER constructor. @@ -292,7 +292,7 @@ do -- TASK_A2A_DISPATCHER self:F( { DetectedItem.ItemID } ) local DetectedSet = DetectedItem.Set - local DetectedZone = DetectedItem.Zone + local DetectedZone = DetectedItem.Zone -- TODO: This seems unused, remove? if DetectedItem.IsDetected == false then @@ -316,7 +316,7 @@ do -- TASK_A2A_DISPATCHER self:F( { DetectedItem.ItemID } ) local DetectedSet = DetectedItem.Set - local DetectedZone = DetectedItem.Zone + local DetectedZone = DetectedItem.Zone -- TODO: This seems unused, remove? local PlayersCount, PlayersReport = self:GetPlayerFriendliesNearBy( DetectedItem )