Code and documentation fixes (#1659)

* Update .lua-format

Adjust for observed coding standards.

* Update ATIS.lua

Correct measurement units and spelling (also changed in Utils.lua).

* Update Utils.lua

Format the file, fix typos, adjust minor text. Rename "celcius" to "celsius". Rename "farenheit" to "fahrenheit".

* Update Warehouse.lua

Adjust measurement unit text.

* Update STTS.lua

Adjust formatting, minor typos, and fix error in documentation (missing blank rows) introduced in previous update.

* Update Range.lua

Adjust minor typos and code formatting. Adjust for celsius/fahrenheit typo correction.

* Update PseudoATC.lua

Adjust for celsius/fahrenheit typo correction in utils.lua.

* Update Point.lua

Code formatting, fix minor typos, adjust for celsius/fahrenheit corrrection in utils.lua.

* Update Range.lua

Minor documentation fix.
This commit is contained in:
TommyC81 2021-12-08 22:52:29 +04:00 committed by GitHub
parent a57b9a9081
commit a4ca4bdc99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1924 additions and 1955 deletions

View File

@ -21,9 +21,9 @@ chop_down_table: true
chop_down_kv_table: true chop_down_kv_table: true
column_table_limit: 500 column_table_limit: 500
table_sep: ',' table_sep: ','
extra_sep_at_table_end: false extra_sep_at_table_end: true
break_after_operator: true break_after_operator: true
single_quote_to_double_quote: true single_quote_to_double_quote: false
double_quote_to_single_quote: false double_quote_to_single_quote: false
spaces_before_call: 1 spaces_before_call: 1
spaces_inside_functiondef_parens: true spaces_inside_functiondef_parens: true

View File

@ -33,15 +33,11 @@
-- @module Core.Point -- @module Core.Point
-- @image Core_Coordinate.JPG -- @image Core_Coordinate.JPG
do -- COORDINATE do -- COORDINATE
--- @type COORDINATE --- @type COORDINATE
-- @extends Core.Base#BASE -- @extends Core.Base#BASE
--- Defines a 3D point in the simulator and with its methods, you can use or manipulate the point in 3D space. --- Defines a 3D point in the simulator and with its methods, you can use or manipulate the point in 3D space.
-- --
-- # 1) Create a COORDINATE object. -- # 1) Create a COORDINATE object.
@ -52,7 +48,6 @@ do -- COORDINATE
-- * @{#COORDINATE.NewFromVec2}(): from a @{DCS#Vec2} and possible altitude. -- * @{#COORDINATE.NewFromVec2}(): from a @{DCS#Vec2} and possible altitude.
-- * @{#COORDINATE.NewFromVec3}(): from a @{DCS#Vec3}. -- * @{#COORDINATE.NewFromVec3}(): from a @{DCS#Vec3}.
-- --
--
-- # 2) Smoke, flare, explode, illuminate at the coordinate. -- # 2) Smoke, flare, explode, illuminate at the coordinate.
-- --
-- At the point a smoke, flare, explosion and illumination bomb can be triggered. Use the following methods: -- At the point a smoke, flare, explosion and illumination bomb can be triggered. Use the following methods:
@ -82,7 +77,6 @@ do -- COORDINATE
-- --
-- * @{#COORDINATE.IlluminationBomb}(): To illuminate the point. -- * @{#COORDINATE.IlluminationBomb}(): To illuminate the point.
-- --
--
-- # 3) Create markings on the map. -- # 3) Create markings on the map.
-- --
-- Place markers (text boxes with clarifications for briefings, target locations or any other reference point) -- Place markers (text boxes with clarifications for briefings, target locations or any other reference point)
@ -128,8 +122,8 @@ do -- COORDINATE
-- ## 4.6) LOS between coordinates. -- ## 4.6) LOS between coordinates.
-- --
-- Calculate if the coordinate has Line of Sight (LOS) with the other given coordinate. -- Calculate if the coordinate has Line of Sight (LOS) with the other given coordinate.
-- Mountains, trees and other objects can be positioned between the two 3D points, preventing visibilty in a straight continuous line. -- Mountains, trees and other objects can be positioned between the two 3D points, preventing visibility in a straight continuous line.
-- The method @{#COORDINATE.IsLOS}() returns if the two coodinates have LOS. -- The method @{#COORDINATE.IsLOS}() returns if the two coordinates have LOS.
-- --
-- ## 4.7) Check the coordinate position. -- ## 4.7) Check the coordinate position.
-- --
@ -139,8 +133,6 @@ do -- COORDINATE
-- * @{#COORDINATE.IsInSphere}(): is in a given sphere. -- * @{#COORDINATE.IsInSphere}(): is in a given sphere.
-- * @{#COORDINATE.IsAtCoordinate2D}(): is in a given coordinate within a specific precision. -- * @{#COORDINATE.IsAtCoordinate2D}(): is in a given coordinate within a specific precision.
-- --
--
--
-- # 5) Measure the simulation environment at the coordinate. -- # 5) Measure the simulation environment at the coordinate.
-- --
-- ## 5.1) Weather specific. -- ## 5.1) Weather specific.
@ -185,7 +177,7 @@ do -- COORDINATE
-- ## 9) Coordinate text generation -- ## 9) Coordinate text generation
-- --
-- * @{#COORDINATE.ToStringBR}(): Generates a Bearing & Range text in the format of DDD for DI where DDD is degrees and DI is distance. -- * @{#COORDINATE.ToStringBR}(): Generates a Bearing & Range text in the format of DDD for DI where DDD is degrees and DI is distance.
-- * @{#COORDINATE.ToStringLL}(): Generates a Latutude & Longutude text. -- * @{#COORDINATE.ToStringLL}(): Generates a Latitude & Longitude text.
-- --
-- ## 10) Drawings on F10 map -- ## 10) Drawings on F10 map
-- --
@ -228,7 +220,6 @@ do -- COORDINATE
LandingReFuAr = "LandingReFuAr", LandingReFuAr = "LandingReFuAr",
} }
--- COORDINATE constructor. --- COORDINATE constructor.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param DCS#Distance x The x coordinate of the Vec3 point, pointing to the North. -- @param DCS#Distance x The x coordinate of the Vec3 point, pointing to the North.
@ -293,7 +284,6 @@ do -- COORDINATE
return self return self
end end
--- Return the coordinates of the COORDINATE in Vec3 format. --- Return the coordinates of the COORDINATE in Vec3 format.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @return DCS#Vec3 The Vec3 format coordinate. -- @return DCS#Vec3 The Vec3 format coordinate.
@ -301,7 +291,6 @@ do -- COORDINATE
return { x = self.x, y = self.y, z = self.z } return { x = self.x, y = self.y, z = self.z }
end end
--- Return the coordinates of the COORDINATE in Vec2 format. --- Return the coordinates of the COORDINATE in Vec2 format.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @return DCS#Vec2 The Vec2 format coordinate. -- @return DCS#Vec2 The Vec2 format coordinate.
@ -406,7 +395,7 @@ do -- COORDINATE
id = world.VolumeType.SPHERE, id = world.VolumeType.SPHERE,
params = { params = {
point = self:GetVec3(), point = self:GetVec3(),
radius = radius, radius = radius
} }
} }
@ -530,7 +519,6 @@ do -- COORDINATE
return umin return umin
end end
--- Calculate the distance from a reference @{#COORDINATE}. --- Calculate the distance from a reference @{#COORDINATE}.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE PointVec2Reference The reference @{#COORDINATE}. -- @param #COORDINATE PointVec2Reference The reference @{#COORDINATE}.
@ -629,7 +617,6 @@ do -- COORDINATE
return RandomVec2 return RandomVec2
end end
--- Return a random Coordinate within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE. --- Return a random Coordinate within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param DCS#Distance OuterRadius Outer radius in meters. -- @param DCS#Distance OuterRadius Outer radius in meters.
@ -641,7 +628,6 @@ do -- COORDINATE
return COORDINATE:NewFromVec2( self:GetRandomVec2InRadius( OuterRadius, InnerRadius ) ) return COORDINATE:NewFromVec2( self:GetRandomVec2InRadius( OuterRadius, InnerRadius ) )
end end
--- Return a random Vec3 within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE. --- Return a random Vec3 within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param DCS#Distance OuterRadius -- @param DCS#Distance OuterRadius
@ -664,14 +650,12 @@ do -- COORDINATE
return land.getHeight( Vec2 ) return land.getHeight( Vec2 )
end end
--- Set the heading of the coordinate, if applicable. --- Set the heading of the coordinate, if applicable.
-- @param #COORDINATE self -- @param #COORDINATE self
function COORDINATE:SetHeading( Heading ) function COORDINATE:SetHeading( Heading )
self.Heading = Heading self.Heading = Heading
end end
--- Get the heading of the coordinate, if applicable. --- Get the heading of the coordinate, if applicable.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @return #number or nil -- @return #number or nil
@ -679,7 +663,6 @@ do -- COORDINATE
return self.Heading return self.Heading
end end
--- Set the velocity of the COORDINATE. --- Set the velocity of the COORDINATE.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #string Velocity Velocity in meters per second. -- @param #string Velocity Velocity in meters per second.
@ -687,7 +670,6 @@ do -- COORDINATE
self.Velocity = Velocity self.Velocity = Velocity
end end
--- Return the velocity of the COORDINATE. --- Return the velocity of the COORDINATE.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @return #number Velocity in meters per second. -- @return #number Velocity in meters per second.
@ -696,7 +678,6 @@ do -- COORDINATE
return Velocity or 0 return Velocity or 0
end end
--- Return velocity text of the COORDINATE. --- Return velocity text of the COORDINATE.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @return #string -- @return #string
@ -705,8 +686,7 @@ do -- COORDINATE
return self:GetVelocityText( Settings ) .. ", " .. self:GetHeadingText( Settings ) return self:GetVelocityText( Settings ) .. ", " .. self:GetHeadingText( Settings )
end end
--- Return a direction vector Vec3 from this COORDINATE to the target COORDINATE.
--- Return a direction vector Vec3 from COORDINATE to the COORDINATE.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE TargetCoordinate The target COORDINATE. -- @param #COORDINATE TargetCoordinate The target COORDINATE.
-- @return DCS#Vec3 DirectionVec3 The direction vector in Vec3 format. -- @return DCS#Vec3 DirectionVec3 The direction vector in Vec3 format.
@ -714,7 +694,6 @@ do -- COORDINATE
return { x = TargetCoordinate.x - self.x, y = TargetCoordinate.y - self.y, z = TargetCoordinate.z - self.z } return { x = TargetCoordinate.x - self.x, y = TargetCoordinate.y - self.y, z = TargetCoordinate.z - self.z }
end end
--- Get a correction in radians of the real magnetic north of the COORDINATE. --- Get a correction in radians of the real magnetic north of the COORDINATE.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @return #number CorrectionRadians The correction in radians. -- @return #number CorrectionRadians The correction in radians.
@ -725,7 +704,6 @@ do -- COORDINATE
return math.atan2( north_posit.z - TargetVec3.z, north_posit.x - TargetVec3.x ) return math.atan2( north_posit.z - TargetVec3.z, north_posit.x - TargetVec3.x )
end end
--- Return an angle in radians from the COORDINATE using a direction vector in Vec3 format. --- Return an angle in radians from the COORDINATE using a direction vector in Vec3 format.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param DCS#Vec3 DirectionVec3 The direction vector in Vec3 format. -- @param DCS#Vec3 DirectionVec3 The direction vector in Vec3 format.
@ -804,8 +782,8 @@ do -- COORDINATE
--- Returns a text of the temperature according the measurement system @{Settings}. --- Returns a text of the temperature according the measurement system @{Settings}.
-- The text will reflect the temperature like this: -- The text will reflect the temperature like this:
-- --
-- - For Russian and European aircraft using the metric system - Degrees Celcius (°C) -- - For Russian and European aircraft using the metric system - Degrees Celsius (°C)
-- - For Americain aircraft we link to the imperial system - Degrees Farenheit (°F) -- - For American aircraft we link to the imperial system - Degrees Fahrenheit (°F)
-- --
-- A text containing a pressure will look like this: -- A text containing a pressure will look like this:
-- --
@ -817,15 +795,15 @@ do -- COORDINATE
-- @return #string Temperature according the measurement system @{Settings}. -- @return #string Temperature according the measurement system @{Settings}.
function COORDINATE:GetTemperatureText( height, Settings ) function COORDINATE:GetTemperatureText( height, Settings )
local DegreesCelcius = self:GetTemperature( height ) local DegreesCelsius = self:GetTemperature( height )
local Settings = Settings or _SETTINGS local Settings = Settings or _SETTINGS
if DegreesCelcius then if DegreesCelsius then
if Settings:IsMetric() then if Settings:IsMetric() then
return string.format( " %-2.2f °C", DegreesCelcius ) return string.format( " %-2.2f °C", DegreesCelsius )
else else
return string.format( " %-2.2f °F", UTILS.CelciusToFarenheit( DegreesCelcius ) ) return string.format( " %-2.2f °F", UTILS.CelsiusToFahrenheit( DegreesCelsius ) )
end end
else else
return " no temperature" return " no temperature"
@ -834,7 +812,6 @@ do -- COORDINATE
return nil return nil
end end
--- Returns the pressure in hPa. --- Returns the pressure in hPa.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param height (Optional) parameter specifying the height ASL. E.g. set height=0 for QNH. -- @param height (Optional) parameter specifying the height ASL. E.g. set height=0 for QNH.
@ -850,8 +827,8 @@ do -- COORDINATE
--- Returns a text of the pressure according the measurement system @{Settings}. --- Returns a text of the pressure according the measurement system @{Settings}.
-- The text will contain always the pressure in hPa and: -- The text will contain always the pressure in hPa and:
-- --
-- - For Russian and European aircraft using the metric system - hPa and mmHg -- - For Russian and European aircraft using the metric system - hPa and mmHg.
-- - For Americain and European aircraft we link to the imperial system - hPa and inHg -- - For American and European aircraft we link to the imperial system - hPa and inHg.
-- --
-- A text containing a pressure will look like this: -- A text containing a pressure will look like this:
-- --
@ -882,7 +859,7 @@ do -- COORDINATE
return nil return nil
end end
--- Returns the heading from this to another coordinate. --- Returns the heading from this to another COORDINATE.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE ToCoordinate -- @param #COORDINATE ToCoordinate
-- @return #number Heading in degrees. -- @return #number Heading in degrees.
@ -939,12 +916,11 @@ do -- COORDINATE
return vec3 return vec3
end end
--- Returns a text documenting the wind direction (from) and strength according the measurement system @{Settings}. --- Returns a text documenting the wind direction (from) and strength according the measurement system @{Settings}.
-- The text will reflect the wind like this: -- The text will reflect the wind like this:
-- --
-- - For Russian and European aircraft using the metric system - Wind direction in degrees (°) and wind speed in meters per second (mps). -- - For Russian and European aircraft using the metric system - Wind direction in degrees (°) and wind speed in meters per second (mps).
-- - For Americain aircraft we link to the imperial system - Wind direction in degrees (°) and wind speed in knots per second (kps). -- - For American aircraft we link to the imperial system - Wind direction in degrees (°) and wind speed in knots per second (kps).
-- --
-- A text containing a pressure will look like this: -- A text containing a pressure will look like this:
-- --
@ -983,10 +959,9 @@ do -- COORDINATE
return ((TargetVec3.x - SourceVec3.x) ^ 2 + (TargetVec3.y - SourceVec3.y) ^ 2 + (TargetVec3.z - SourceVec3.z) ^ 2) ^ 0.5 return ((TargetVec3.x - SourceVec3.x) ^ 2 + (TargetVec3.y - SourceVec3.y) ^ 2 + (TargetVec3.z - SourceVec3.z) ^ 2) ^ 0.5
end end
--- Provides a bearing text in degrees. --- Provides a bearing text in degrees.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #number AngleRadians The angle in randians. -- @param #number AngleRadians The angle in radians.
-- @param #number Precision The precision. -- @param #number Precision The precision.
-- @param Core.Settings#SETTINGS Settings -- @param Core.Settings#SETTINGS Settings
-- @return #string The bearing text in degrees. -- @return #string The bearing text in degrees.
@ -1057,8 +1032,6 @@ do -- COORDINATE
end end
end end
--- Return the velocity text of the COORDINATE. --- Return the velocity text of the COORDINATE.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @return #string Velocity text. -- @return #string Velocity text.
@ -1076,7 +1049,6 @@ do -- COORDINATE
end end
end end
--- Return the heading text of the COORDINATE. --- Return the heading text of the COORDINATE.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @return #string Heading text. -- @return #string Heading text.
@ -1089,10 +1061,9 @@ do -- COORDINATE
end end
end end
--- Provides a Bearing / Range string --- Provides a Bearing / Range string
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #number AngleRadians The angle in randians -- @param #number AngleRadians The angle in radians
-- @param #number Distance The distance -- @param #number Distance The distance
-- @param Core.Settings#SETTINGS Settings -- @param Core.Settings#SETTINGS Settings
-- @return #string The BR Text -- @return #string The BR Text
@ -1110,7 +1081,7 @@ do -- COORDINATE
--- Provides a Bearing / Range / Altitude string --- Provides a Bearing / Range / Altitude string
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #number AngleRadians The angle in randians -- @param #number AngleRadians The angle in radians
-- @param #number Distance The distance -- @param #number Distance The distance
-- @param Core.Settings#SETTINGS Settings -- @param Core.Settings#SETTINGS Settings
-- @return #string The BRA Text -- @return #string The BRA Text
@ -1127,7 +1098,6 @@ do -- COORDINATE
return BRAText return BRAText
end end
--- Set altitude. --- Set altitude.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #number altitude New altitude in meters. -- @param #number altitude New altitude in meters.
@ -1233,7 +1203,6 @@ do -- COORDINATE
return RoutePoint return RoutePoint
end end
--- Build a Waypoint Air "Turning Point". --- Build a Waypoint Air "Turning Point".
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE.WaypointAltType AltType The altitude type. -- @param #COORDINATE.WaypointAltType AltType The altitude type.
@ -1245,7 +1214,6 @@ do -- COORDINATE
return self:WaypointAir( AltType, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, Speed, true, nil, DCSTasks, description ) return self:WaypointAir( AltType, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, Speed, true, nil, DCSTasks, description )
end end
--- Build a Waypoint Air "Fly Over Point". --- Build a Waypoint Air "Fly Over Point".
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE.WaypointAltType AltType The altitude type. -- @param #COORDINATE.WaypointAltType AltType The altitude type.
@ -1255,7 +1223,6 @@ do -- COORDINATE
return self:WaypointAir( AltType, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.FlyoverPoint, Speed ) return self:WaypointAir( AltType, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.FlyoverPoint, Speed )
end end
--- Build a Waypoint Air "Take Off Parking Hot". --- Build a Waypoint Air "Take Off Parking Hot".
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE.WaypointAltType AltType The altitude type. -- @param #COORDINATE.WaypointAltType AltType The altitude type.
@ -1265,7 +1232,6 @@ do -- COORDINATE
return self:WaypointAir( AltType, COORDINATE.WaypointType.TakeOffParkingHot, COORDINATE.WaypointAction.FromParkingAreaHot, Speed ) return self:WaypointAir( AltType, COORDINATE.WaypointType.TakeOffParkingHot, COORDINATE.WaypointAction.FromParkingAreaHot, Speed )
end end
--- Build a Waypoint Air "Take Off Parking". --- Build a Waypoint Air "Take Off Parking".
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE.WaypointAltType AltType The altitude type. -- @param #COORDINATE.WaypointAltType AltType The altitude type.
@ -1275,7 +1241,6 @@ do -- COORDINATE
return self:WaypointAir( AltType, COORDINATE.WaypointType.TakeOffParking, COORDINATE.WaypointAction.FromParkingArea, Speed ) return self:WaypointAir( AltType, COORDINATE.WaypointType.TakeOffParking, COORDINATE.WaypointAction.FromParkingArea, Speed )
end end
--- Build a Waypoint Air "Take Off Runway". --- Build a Waypoint Air "Take Off Runway".
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE.WaypointAltType AltType The altitude type. -- @param #COORDINATE.WaypointAltType AltType The altitude type.
@ -1285,7 +1250,6 @@ do -- COORDINATE
return self:WaypointAir( AltType, COORDINATE.WaypointType.TakeOff, COORDINATE.WaypointAction.FromRunway, Speed ) return self:WaypointAir( AltType, COORDINATE.WaypointType.TakeOff, COORDINATE.WaypointAction.FromRunway, Speed )
end end
--- Build a Waypoint Air "Landing". --- Build a Waypoint Air "Landing".
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param DCS#Speed Speed Airspeed in km/h. -- @param DCS#Speed Speed Airspeed in km/h.
@ -1316,7 +1280,6 @@ do -- COORDINATE
return self:WaypointAir( nil, COORDINATE.WaypointType.LandingReFuAr, COORDINATE.WaypointAction.LandingReFuAr, Speed, false, airbase, DCSTasks, description, timeReFuAr or 10 ) return self:WaypointAir( nil, COORDINATE.WaypointType.LandingReFuAr, COORDINATE.WaypointAction.LandingReFuAr, Speed, false, airbase, DCSTasks, description, timeReFuAr or 10 )
end end
--- Build an ground type route point. --- Build an ground type route point.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #number Speed (Optional) Speed in km/h. The default speed is 20 km/h. -- @param #number Speed (Optional) Speed in km/h. The default speed is 20 km/h.
@ -1461,7 +1424,7 @@ do -- COORDINATE
--- Gets the nearest parking spot. --- Gets the nearest parking spot.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param Wrapper.Airbase#AIRBASE airbase (Optional) Search only parking spots at this airbase. -- @param Wrapper.Airbase#AIRBASE airbase (Optional) Search only parking spots at this airbase.
-- @param Wrapper.Airbase#Terminaltype terminaltype (Optional) Type of the terminal. Default any execpt valid spawn points on runway. -- @param Wrapper.Airbase#Terminaltype terminaltype (Optional) Type of the terminal. Default any except valid spawn points on runway.
-- @param #boolean free (Optional) If true, returns the closest free spot. If false, returns the closest occupied spot. If nil, returns the closest spot regardless of free or occupied. -- @param #boolean free (Optional) If true, returns the closest free spot. If false, returns the closest occupied spot. If nil, returns the closest spot regardless of free or occupied.
-- @return Core.Point#COORDINATE Coordinate of the nearest parking spot. -- @return Core.Point#COORDINATE Coordinate of the nearest parking spot.
-- @return #number Terminal ID. -- @return #number Terminal ID.
@ -1554,7 +1517,6 @@ do -- COORDINATE
return COORDINATE:NewFromVec2( vec2 ) return COORDINATE:NewFromVec2( vec2 )
end end
--- Returns a table of coordinates to a destination using only roads or railroads. --- Returns a table of coordinates to a destination using only roads or railroads.
-- The first point is the closest point on road of the given coordinate. -- The first point is the closest point on road of the given coordinate.
-- By default, the last point is the closest point on road of the ToCoord. Hence, the coordinate itself and the final ToCoord are not necessarily included in the path. -- By default, the last point is the closest point on road of the ToCoord. Hence, the coordinate itself and the final ToCoord are not necessarily included in the path.
@ -1563,7 +1525,7 @@ do -- COORDINATE
-- @param #boolean IncludeEndpoints (Optional) Include the coordinate itself and the ToCoordinate in the path. -- @param #boolean IncludeEndpoints (Optional) Include the coordinate itself and the ToCoordinate in the path.
-- @param #boolean Railroad (Optional) If true, path on railroad is returned. Default false. -- @param #boolean Railroad (Optional) If true, path on railroad is returned. Default false.
-- @param #boolean MarkPath (Optional) If true, place markers on F10 map along the path. -- @param #boolean MarkPath (Optional) If true, place markers on F10 map along the path.
-- @param #boolean SmokePath (Optional) If true, put (green) smoke along the -- @param #boolean SmokePath (Optional) If true, put (green) smoke along the the path.
-- @return #table Table of coordinates on road. If no path on road can be found, nil is returned or just the endpoints. -- @return #table Table of coordinates on road. If no path on road can be found, nil is returned or just the endpoints.
-- @return #number Tonal length of path. -- @return #number Tonal length of path.
-- @return #boolean If true a valid path on road/rail was found. If false, only the direct way is possible. -- @return #boolean If true a valid path on road/rail was found. If false, only the direct way is possible.
@ -1664,7 +1626,6 @@ do -- COORDINATE
return self:GetSurfaceType() == land.SurfaceType.LAND return self:GetSurfaceType() == land.SurfaceType.LAND
end end
--- Checks if the surface type is road. --- Checks if the surface type is road.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @return #boolean If true, the surface type at the coordinate is a road. -- @return #boolean If true, the surface type at the coordinate is a road.
@ -1693,7 +1654,6 @@ do -- COORDINATE
return self:GetSurfaceType() == land.SurfaceType.WATER return self:GetSurfaceType() == land.SurfaceType.WATER
end end
--- Creates an explosion at the point of a certain intensity. --- Creates an explosion at the point of a certain intensity.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #number ExplosionIntensity Intensity of the explosion in kg TNT. Default 100 kg. -- @param #number ExplosionIntensity Intensity of the explosion in kg TNT. Default 100 kg.
@ -1719,7 +1679,6 @@ do -- COORDINATE
trigger.action.illuminationBomb( self:GetVec3(), power ) trigger.action.illuminationBomb( self:GetVec3(), power )
end end
--- Smokes the point in a color. --- Smokes the point in a color.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param Utilities.Utils#SMOKECOLOR SmokeColor -- @param Utilities.Utils#SMOKECOLOR SmokeColor
@ -1989,7 +1948,7 @@ do -- COORDINATE
--- Line to all. --- Line to all.
-- Creates a line on the F10 map from one point to another. -- Creates a line on the F10 map from one point to another.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE Endpoint COORDIANTE to where the line is drawn. -- @param #COORDINATE Endpoint COORDINATE to where the line is drawn.
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All. -- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default). -- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
-- @param #number Alpha Transparency [0,1]. Default 1. -- @param #number Alpha Transparency [0,1]. Default 1.
@ -2014,7 +1973,7 @@ do -- COORDINATE
--- Circle to all. --- Circle to all.
-- Creates a circle on the map with a given radius, color, fill color, and outline. -- Creates a circle on the map with a given radius, color, fill color, and outline.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #numberr Radius Radius in meters. Default 1000 m. -- @param #number Radius Radius in meters. Default 1000 m.
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All. -- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default). -- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
-- @param #number Alpha Transparency [0,1]. Default 1. -- @param #number Alpha Transparency [0,1]. Default 1.
@ -2046,7 +2005,7 @@ do -- COORDINATE
--- Rectangle to all. Creates a rectangle on the map from the COORDINATE in one corner to the end COORDINATE in the opposite corner. --- Rectangle to all. Creates a rectangle on the map from the COORDINATE in one corner to the end COORDINATE in the opposite corner.
-- Creates a line on the F10 map from one point to another. -- Creates a line on the F10 map from one point to another.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE Endpoint COORDIANTE in the opposite corner. -- @param #COORDINATE Endpoint COORDINATE in the opposite corner.
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All. -- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default). -- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
-- @param #number Alpha Transparency [0,1]. Default 1. -- @param #number Alpha Transparency [0,1]. Default 1.
@ -2244,7 +2203,6 @@ do -- COORDINATE
return IsLOS return IsLOS
end end
--- Returns if a Coordinate is in a certain Radius of this Coordinate in 2D plane using the X and Z axis. --- Returns if a Coordinate is in a certain Radius of this Coordinate in 2D plane using the X and Z axis.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE Coordinate The coordinate that will be tested if it is in the radius of this coordinate. -- @param #COORDINATE Coordinate The coordinate that will be tested if it is in the radius of this coordinate.
@ -2260,7 +2218,6 @@ do -- COORDINATE
return InRadius return InRadius
end end
--- Returns if a Coordinate is in a certain radius of this Coordinate in 3D space using the X, Y and Z axis. --- Returns if a Coordinate is in a certain radius of this Coordinate in 3D space using the X, Y and Z axis.
-- So Radius defines the radius of the a Sphere in 3D space around this coordinate. -- So Radius defines the radius of the a Sphere in 3D space around this coordinate.
-- @param #COORDINATE self -- @param #COORDINATE self
@ -2567,7 +2524,6 @@ do -- COORDINATE
return delta / 60 return delta / 60
end end
--- Return a BR string from a COORDINATE to the COORDINATE. --- Return a BR string from a COORDINATE to the COORDINATE.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE FromCoordinate The coordinate to measure the distance and the bearing from. -- @param #COORDINATE FromCoordinate The coordinate to measure the distance and the bearing from.
@ -2743,7 +2699,6 @@ do -- COORDINATE
end end
--- Provides a coordinate string of the point, based on the A2A coordinate format system. --- Provides a coordinate string of the point, based on the A2A coordinate format system.
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable -- @param Wrapper.Controllable#CONTROLLABLE Controllable
@ -2814,7 +2769,6 @@ do -- COORDINATE
end end
end end
if ModeA2A == nil then if ModeA2A == nil then
local IsAir = Controllable and (Controllable:IsAirPlane() or Controllable:IsHelicopter()) or false local IsAir = Controllable and (Controllable:IsAirPlane() or Controllable:IsHelicopter()) or false
if IsAir then if IsAir then
@ -2824,7 +2778,6 @@ do -- COORDINATE
end end
end end
if ModeA2A == true then if ModeA2A == true then
return self:ToStringA2A( Controllable, Settings ) return self:ToStringA2A( Controllable, Settings )
else else
@ -2899,7 +2852,6 @@ do -- POINT_VEC3
-- @field #POINT_VEC3.RoutePointAction RoutePointAction -- @field #POINT_VEC3.RoutePointAction RoutePointAction
-- @extends #COORDINATE -- @extends #COORDINATE
--- Defines a 3D point in the simulator and with its methods, you can use or manipulate the point in 3D space. --- Defines a 3D point in the simulator and with its methods, you can use or manipulate the point in 3D space.
-- --
-- **Important Note:** Most of the functions in this section were taken from MIST, and reworked to OO concepts. -- **Important Note:** Most of the functions in this section were taken from MIST, and reworked to OO concepts.
@ -2907,7 +2859,6 @@ do -- POINT_VEC3
-- I want to emphasize that the formulas embedded in the MIST framework were created by Grimes or previous authors, -- I want to emphasize that the formulas embedded in the MIST framework were created by Grimes or previous authors,
-- who you can find on the Eagle Dynamics Forums. -- who you can find on the Eagle Dynamics Forums.
-- --
--
-- ## POINT_VEC3 constructor -- ## POINT_VEC3 constructor
-- --
-- A new POINT_VEC3 object can be created with: -- A new POINT_VEC3 object can be created with:
@ -2929,19 +2880,16 @@ do -- POINT_VEC3
-- --
-- local Vec3 = PointVec3:AddX( 100 ):AddZ( 150 ):GetVec3() -- local Vec3 = PointVec3:AddX( 100 ):AddZ( 150 ):GetVec3()
-- --
--
-- ## 3D calculation methods -- ## 3D calculation methods
-- --
-- Various calculation methods exist to use or manipulate 3D space. Find below a short description of each method: -- Various calculation methods exist to use or manipulate 3D space. Find below a short description of each method:
-- --
--
-- ## Point Randomization -- ## Point Randomization
-- --
-- Various methods exist to calculate random locations around a given 3D point. -- Various methods exist to calculate random locations around a given 3D point.
-- --
-- * @{#POINT_VEC3.GetRandomPointVec3InRadius}(): Provides a random 3D point around the current 3D point, in the given inner to outer band. -- * @{#POINT_VEC3.GetRandomPointVec3InRadius}(): Provides a random 3D point around the current 3D point, in the given inner to outer band.
-- --
--
-- @field #POINT_VEC3 -- @field #POINT_VEC3
POINT_VEC3 = { POINT_VEC3 = {
ClassName = "POINT_VEC3", ClassName = "POINT_VEC3",
@ -3136,8 +3084,6 @@ do -- POINT_VEC2
ClassName = "POINT_VEC2", ClassName = "POINT_VEC2",
} }
--- POINT_VEC2 constructor. --- POINT_VEC2 constructor.
-- @param #POINT_VEC2 self -- @param #POINT_VEC2 self
-- @param DCS#Distance x The x coordinate of the Vec3 point, pointing to the North. -- @param DCS#Distance x The x coordinate of the Vec3 point, pointing to the North.
@ -3289,11 +3235,10 @@ do -- POINT_VEC2
-- @param #number Altitude The Altitude to add. If nothing (nil) is given, then the current land altitude is set. -- @param #number Altitude The Altitude to add. If nothing (nil) is given, then the current land altitude is set.
-- @return #POINT_VEC2 -- @return #POINT_VEC2
function POINT_VEC2:AddAlt( Altitude ) function POINT_VEC2:AddAlt( Altitude )
self.y = land.getHeight( { x = self.x, y = self.z } ) + Altitude or 0 self.y = land.getHeight( { x = self.x, y = self.z } ) + (Altitude or 0)
return self return self
end end
--- Return a random POINT_VEC2 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC2. --- Return a random POINT_VEC2 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC2.
-- @param #POINT_VEC2 self -- @param #POINT_VEC2 self
-- @param DCS#Distance OuterRadius -- @param DCS#Distance OuterRadius
@ -3321,4 +3266,3 @@ do -- POINT_VEC2
end end

View File

@ -742,7 +742,7 @@ function PSEUDOATC:ReportWeather(GID, UID, position, location)
local T=position:GetTemperature() local T=position:GetTemperature()
-- Correct unit system. -- Correct unit system.
local _T=string.format('%d°F', UTILS.CelciusToFarenheit(T)) local _T=string.format('%d°F', UTILS.CelsiusToFahrenheit(T))
if settings:IsMetric() then if settings:IsMetric() then
_T=string.format('%d°C', T) _T=string.format('%d°C', T)
end end

View File

@ -260,7 +260,7 @@
-- -- Add bombing targets. A good hit is if the bomb falls less then 50 m from the target. -- -- Add bombing targets. A good hit is if the bomb falls less then 50 m from the target.
-- GoldwaterRange:AddBombingTargets(bombtargets, 50) -- GoldwaterRange:AddBombingTargets(bombtargets, 50)
-- --
-- -- Start range. -- -- Start Range.
-- GoldwaterRange:Start() -- GoldwaterRange:Start()
-- --
-- The [476th - Air Weapons Range Objects mod](http://www.476vfightergroup.com/downloads.php?do=file&id=287) is (implicitly) used in this example. -- The [476th - Air Weapons Range Objects mod](http://www.476vfightergroup.com/downloads.php?do=file&id=287) is (implicitly) used in this example.
@ -329,7 +329,7 @@ RANGE = {
instructor = nil, instructor = nil,
rangecontrolfreq = nil, rangecontrolfreq = nil,
rangecontrol = nil, rangecontrol = nil,
soundpath = "Range Soundfiles/" soundpath = "Range Soundfiles/",
} }
--- Default range parameters. --- Default range parameters.
@ -345,7 +345,7 @@ RANGE.Defaults = {
boxlength = 3000, -- meters boxlength = 3000, -- meters
boxwidth = 300, -- meters boxwidth = 300, -- meters
goodpass = 20, -- targethits per pass goodpass = 20, -- targethits per pass
foulline = 610 -- meters foulline = 610, -- meters
} }
--- Target type, i.e. unit, static, or coordinate. --- Target type, i.e. unit, static, or coordinate.
@ -500,7 +500,7 @@ RANGE.Sound = {
IRDecimal = { filename = "IR-Decimal.ogg", duration = 0.54 }, IRDecimal = { filename = "IR-Decimal.ogg", duration = 0.54 },
IRMegaHertz = { filename = "IR-MegaHertz.ogg", duration = 0.87 }, IRMegaHertz = { filename = "IR-MegaHertz.ogg", duration = 0.87 },
IREnterRange = { filename = "IR-EnterRange.ogg", duration = 4.83 }, IREnterRange = { filename = "IR-EnterRange.ogg", duration = 4.83 },
IRExitRange = { filename = "IR-ExitRange.ogg", duration = 3.10 } IRExitRange = { filename = "IR-ExitRange.ogg", duration = 3.10 },
} }
--- Global list of all defined range names. --- Global list of all defined range names.
@ -1089,7 +1089,7 @@ end
--- Set sound files folder within miz file. --- Set sound files folder within miz file.
-- @param #RANGE self -- @param #RANGE self
-- @param #string path Path for sound files. Default "ATIS Soundfiles/". Mind the slash "/" at the end! -- @param #string path Path for sound files. Default "Range Soundfiles/". Mind the slash "/" at the end!
-- @return #RANGE self -- @return #RANGE self
function RANGE:SetSoundfilesPath( path ) function RANGE:SetSoundfilesPath( path )
self.soundpath = tostring( path or "Range Soundfiles/" ) self.soundpath = tostring( path or "Range Soundfiles/" )
@ -1384,12 +1384,14 @@ end
-- --
-- -- Setup a Range -- -- Setup a Range
-- RangeOne = RANGE:New( "Range One" ) -- RangeOne = RANGE:New( "Range One" )
-- -- Find the STATIC target object as setup in the ME -- -- Find the STATIC target object as setup in the ME.
-- RangeOneBombTarget = STATIC:FindByName( "RangeOneBombTarget" ): -- RangeOneBombTarget = STATIC:FindByName( "RangeOneBombTarget" )
-- -- Add the coordinate of the STATIC target object as a bomb target (thus keeping the bomb function active, even if the STATIC target is destroyed) -- -- Add the coordinate of the STATIC target object as a bomb target (thus keeping the bomb function active, even if the STATIC target is destroyed).
-- RangeOne:AddBombingTargetCoordinate( RangeOneBombTarget:GetCoordinate(), "RangeOneBombTarget", 50) -- RangeOne:AddBombingTargetCoordinate( RangeOneBombTarget:GetCoordinate(), "RangeOneBombTarget", 50)
-- -- Or, add the coordinate of the STATIC target object as a bomb target using default values (name will be "Bomb Target", goodhitrange will be 25 m) -- -- Or, add the coordinate of the STATIC target object as a bomb target using default values (name will be "Bomb Target", goodhitrange will be 25 m).
-- RangeOne:AddBombingTargetCoordinate( RangeOneBombTarget:GetCoordinate() ) -- RangeOne:AddBombingTargetCoordinate( RangeOneBombTarget:GetCoordinate() )
-- -- Start Range.
-- RangeOne:Start()
-- --
function RANGE:AddBombingTargetCoordinate( coord, name, goodhitrange ) function RANGE:AddBombingTargetCoordinate( coord, name, goodhitrange )
@ -1436,6 +1438,17 @@ end
-- @param #string namepit Name of the strafe pit target object. -- @param #string namepit Name of the strafe pit target object.
-- @param #string namefoulline Name of the foul line distance marker object. -- @param #string namefoulline Name of the foul line distance marker object.
-- @return #number Foul line distance in meters. -- @return #number Foul line distance in meters.
-- @usage
--
-- -- Setup a Range
-- RangeOne = RANGE:New( "Range One" )
-- -- Get distance between strafe target objext and foul line distance marker object.
-- RangeOneFoulDistance = RangeOne:GetFoullineDistance( "RangeOneStrafeTarget" , "RangeOneFoulLineObject" )
-- -- Add a strafe pit using the measured foul line distance. Where nil is used, strafe pit default values will be used - adjust as required.
-- RangeOne:AddStrafePit( "RangeOneStrafeTarget", nil, nil, nil, nil, nil, RangeOneFoulDistance )
-- -- Start Range.
-- RangeOne:Start()
--
function RANGE:GetFoullineDistance( namepit, namefoulline ) function RANGE:GetFoullineDistance( namepit, namefoulline )
self:F( { namepit = namepit, namefoulline = namefoulline } ) self:F( { namepit = namepit, namefoulline = namefoulline } )
@ -2107,7 +2120,7 @@ function RANGE:onafterSave( From, Event, To )
_savefile( filename, scores ) _savefile( filename, scores )
end end
--- Function called before save event. Checks that io and lfs are desanitized. --- Function called before load event. Checks that io and lfs are desanitized.
-- @param #RANGE self -- @param #RANGE self
-- @param #string From From state. -- @param #string From From state.
-- @param #string Event Event. -- @param #string Event Event.
@ -2654,7 +2667,7 @@ function RANGE:_DisplayRangeWeather( _unitname )
local tW = string.format( "%.1f m/s", Ws ) local tW = string.format( "%.1f m/s", Ws )
local tP = string.format( "%.1f mmHg", P * hPa2mmHg ) local tP = string.format( "%.1f mmHg", P * hPa2mmHg )
if settings:IsImperial() then if settings:IsImperial() then
-- tT=string.format("%d°F", UTILS.CelciusToFarenheit(T)) -- tT=string.format("%d°F", UTILS.CelsiusToFahrenheit(T))
tW = string.format( "%.1f knots", UTILS.MpsToKnots( Ws ) ) tW = string.format( "%.1f knots", UTILS.MpsToKnots( Ws ) )
tP = string.format( "%.2f inHg", P * hPa2inHg ) tP = string.format( "%.2f inHg", P * hPa2inHg )
end end

View File

@ -1601,7 +1601,7 @@ WAREHOUSE = {
-- @field #number range Range of the unit in meters. -- @field #number range Range of the unit in meters.
-- @field #number speedmax Maximum speed in km/h the group can do. -- @field #number speedmax Maximum speed in km/h the group can do.
-- @field #number size Maximum size in length and with of the asset in meters. -- @field #number size Maximum size in length and with of the asset in meters.
-- @field #number weight The weight of the whole asset group in kilo gramms. -- @field #number weight The weight of the whole asset group in kilograms.
-- @field DCS#Object.Desc DCSdesc All DCS descriptors. -- @field DCS#Object.Desc DCSdesc All DCS descriptors.
-- @field #WAREHOUSE.Attribute attribute Generalized attribute of the group. -- @field #WAREHOUSE.Attribute attribute Generalized attribute of the group.
-- @field #table cargobay Array of cargo bays of all units in an asset group. -- @field #table cargobay Array of cargo bays of all units in an asset group.

View File

@ -67,7 +67,7 @@
-- @field #string activerunway The active runway specified by the user. -- @field #string activerunway The active runway specified by the user.
-- @field #number subduration Duration how long subtitles are displayed in seconds. -- @field #number subduration Duration how long subtitles are displayed in seconds.
-- @field #boolean metric If true, use metric units. If false, use imperial (default). -- @field #boolean metric If true, use metric units. If false, use imperial (default).
-- @field #boolean PmmHg If true, give pressure in millimeters of Mercury. Default is inHg for imperial and hecto Pascal (=mili Bars) for metric units. -- @field #boolean PmmHg If true, give pressure in millimeters of Mercury. Default is inHg for imperial and hectopascal (hPa, which is the same as millibar - mbar) for metric units.
-- @field #boolean qnhonly If true, suppresses reporting QFE. Default is to report both QNH and QFE. -- @field #boolean qnhonly If true, suppresses reporting QFE. Default is to report both QNH and QFE.
-- @field #boolean TDegF If true, give temperature in degrees Fahrenheit. Default is in degrees Celsius independent of chosen unit system. -- @field #boolean TDegF If true, give temperature in degrees Fahrenheit. Default is in degrees Celsius independent of chosen unit system.
-- @field #number zuludiff Time difference local vs. zulu in hours. -- @field #number zuludiff Time difference local vs. zulu in hours.
@ -239,7 +239,7 @@
-- --
-- atisBatumi:SetMetricUnits() -- atisBatumi:SetMetricUnits()
-- --
-- With this, wind speed is given in meters per second, pressure in hecto Pascal (mbar), visibility in kilometers etc. -- With this, wind speed is given in meters per second, pressure in hectopascal (hPa, which is the same as millibar - mbar), visibility in kilometers etc.
-- --
-- # Sound Files -- # Sound Files
-- --
@ -1459,8 +1459,8 @@ function ATIS:onafterBroadcast(From, Event, To)
-- Convert to °F. -- Convert to °F.
if self.TDegF then if self.TDegF then
temperature=UTILS.CelciusToFarenheit(temperature) temperature=UTILS.CelsiusToFahrenheit(temperature)
dewpoint=UTILS.CelciusToFarenheit(dewpoint) dewpoint=UTILS.CelsiusToFahrenheit(dewpoint)
end end
local TEMPERATURE=string.format("%d", math.abs(temperature)) local TEMPERATURE=string.format("%d", math.abs(temperature))
@ -2280,7 +2280,7 @@ function ATIS:onafterReport(From, Event, To, Text)
local text=string.gsub(text, "°F", "degrees Fahrenheit") local text=string.gsub(text, "°F", "degrees Fahrenheit")
local text=string.gsub(text, "inHg", "inches of Mercury") local text=string.gsub(text, "inHg", "inches of Mercury")
local text=string.gsub(text, "mmHg", "millimeters of Mercury") local text=string.gsub(text, "mmHg", "millimeters of Mercury")
local text=string.gsub(text, "hPa", "hecto Pascals") local text=string.gsub(text, "hPa", "hectopascals")
local text=string.gsub(text, "m/s", "meters per second") local text=string.gsub(text, "m/s", "meters per second")
-- Replace ";" by "." -- Replace ";" by "."

View File

@ -3,9 +3,11 @@
-- --
-- @module Utils.STTS -- @module Utils.STTS
-- @image MOOSE.JPG -- @image MOOSE.JPG
--- [DCS Enum world](https://wiki.hoggitworld.com/view/DCS_enum_world) --- [DCS Enum world](https://wiki.hoggitworld.com/view/DCS_enum_world)
-- @type STTS -- @type STTS
-- @field #string DIRECTORY Path of the SRS directory. -- @field #string DIRECTORY Path of the SRS directory.
--- Simple Text-To-Speech --- Simple Text-To-Speech
-- --
-- Version 0.4 - Compatible with SRS version 1.9.6.0+ -- Version 0.4 - Compatible with SRS version 1.9.6.0+
@ -40,7 +42,7 @@
-- * OPTIONAL - Speed -10 to +10 -- * OPTIONAL - Speed -10 to +10
-- * OPTIONAL - Gender male, female or neuter -- * OPTIONAL - Gender male, female or neuter
-- * OPTIONAL - Culture - en-US, en-GB etc -- * OPTIONAL - Culture - en-US, en-GB etc
-- * OPTIONAL - Voice - a specfic voice by name. Run DCS-SR-ExternalAudio.exe with --help to get the ones you can use on the command line -- * OPTIONAL - Voice - a specific voice by name. Run DCS-SR-ExternalAudio.exe with --help to get the ones you can use on the command line
-- * OPTIONAL - Google TTS - Switch to Google Text To Speech - Requires STTS.GOOGLE_CREDENTIALS path and Google project setup correctly -- * OPTIONAL - Google TTS - Switch to Google Text To Speech - Requires STTS.GOOGLE_CREDENTIALS path and Google project setup correctly
-- --
-- --
@ -89,7 +91,7 @@ STTS.SRS_PORT = 5002
--- Google credentials file --- Google credentials file
STTS.GOOGLE_CREDENTIALS = "C:\\Users\\Ciaran\\Downloads\\googletts.json" STTS.GOOGLE_CREDENTIALS = "C:\\Users\\Ciaran\\Downloads\\googletts.json"
--- DONT CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING --- DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING
STTS.EXECUTABLE = "DCS-SR-ExternalAudio.exe" STTS.EXECUTABLE = "DCS-SR-ExternalAudio.exe"
--- Function for UUID. --- Function for UUID.
@ -117,11 +119,11 @@ function STTS.round( x, n )
end end
--- Function returns estimated speech time in seconds. --- Function returns estimated speech time in seconds.
-- Assumptions for time calc: 100 Words per min, avarage of 5 letters for english word so -- Assumptions for time calc: 100 Words per min, average of 5 letters for english word so
-- --
-- * 5 chars * 100wpm = 500 characters per min = 8.3 chars per second -- * 5 chars * 100wpm = 500 characters per min = 8.3 chars per second
-- --
-- So lengh of msg / 8.3 = number of seconds needed to read it. rounded down to 8 chars per sec map function: -- So length of msg / 8.3 = number of seconds needed to read it. rounded down to 8 chars per sec map function:
-- --
-- * (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min -- * (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
-- --

View File

@ -11,7 +11,6 @@
-- @module Utils -- @module Utils
-- @image MOOSE.JPG -- @image MOOSE.JPG
--- @type SMOKECOLOR --- @type SMOKECOLOR
-- @field Green -- @field Green
-- @field Red -- @field Red
@ -58,10 +57,9 @@ DCSMAP = {
PersianGulf = "PersianGulf", PersianGulf = "PersianGulf",
TheChannel = "TheChannel", TheChannel = "TheChannel",
Syria = "Syria", Syria = "Syria",
MarianaIslands="MarianaIslands" MarianaIslands = "MarianaIslands",
} }
--- See [DCS_enum_callsigns](https://wiki.hoggitworld.com/view/DCS_enum_callsigns) --- See [DCS_enum_callsigns](https://wiki.hoggitworld.com/view/DCS_enum_callsigns)
-- @type CALLSIGN -- @type CALLSIGN
CALLSIGN = { CALLSIGN = {
@ -201,7 +199,6 @@ UTILS.IsInstanceOf = function( object, className )
return false return false
end end
--- Deep copy a table. See http://lua-users.org/wiki/CopyTable --- Deep copy a table. See http://lua-users.org/wiki/CopyTable
-- @param #table object The input table. -- @param #table object The input table.
-- @return #table Copy of the input table. -- @return #table Copy of the input table.
@ -233,7 +230,6 @@ UTILS.DeepCopy = function(object)
return objectreturn return objectreturn
end end
--- Porting in Slmod's serialize_slmod2. --- Porting in Slmod's serialize_slmod2.
-- @param #table tbl Input table. -- @param #table tbl Input table.
UTILS.OneLineSerialize = function( tbl ) -- serialization of a table all on a single line, no comments, made to replace old get_table_string function UTILS.OneLineSerialize = function( tbl ) -- serialization of a table all on a single line, no comments, made to replace old get_table_string function
@ -326,7 +322,6 @@ UTILS.BasicSerialize = function(s)
end end
end end
UTILS.ToDegree = function( angle ) UTILS.ToDegree = function( angle )
return angle * 180 / math.pi return angle * 180 / math.pi
end end
@ -412,21 +407,21 @@ UTILS.KnotsToMps = function( knots )
return knots / 1.94384 -- * 1852 / 3600 return knots / 1.94384 -- * 1852 / 3600
end end
--- Convert temperature from Celsius to Farenheit. --- Convert temperature from Celsius to Fahrenheit.
-- @param #number Celcius Temperature in degrees Celsius. -- @param #number Celsius Temperature in degrees Celsius.
-- @return #number Temperature in degrees Farenheit. -- @return #number Temperature in degrees Fahrenheit.
UTILS.CelciusToFarenheit = function( Celcius ) UTILS.CelsiusToFahrenheit = function( Celsius )
return Celcius * 9/5 + 32 return Celsius * 9 / 5 + 32
end end
--- Convert pressure from hecto Pascal (hPa) to inches of mercury (inHg). --- Convert pressure from hectopascal (hPa) to inches of mercury (inHg).
-- @param #number hPa Pressure in hPa. -- @param #number hPa Pressure in hPa.
-- @return #number Pressure in inHg. -- @return #number Pressure in inHg.
UTILS.hPa2inHg = function( hPa ) UTILS.hPa2inHg = function( hPa )
return hPa * 0.0295299830714 return hPa * 0.0295299830714
end end
--- Convert knots to alitude corrected KIAS, e.g. for tankers. --- Convert knots to altitude corrected KIAS, e.g. for tankers.
-- @param #number knots Speed in knots. -- @param #number knots Speed in knots.
-- @param #number altitude Altitude in feet -- @param #number altitude Altitude in feet
-- @return #number Corrected KIAS -- @return #number Corrected KIAS
@ -434,14 +429,14 @@ UTILS.KnotsToAltKIAS = function( knots, altitude )
return (knots * 0.018 * (altitude / 1000)) + knots return (knots * 0.018 * (altitude / 1000)) + knots
end end
--- Convert pressure from hecto Pascal (hPa) to millimeters of mercury (mmHg). --- Convert pressure from hectopascal (hPa) to millimeters of mercury (mmHg).
-- @param #number hPa Pressure in hPa. -- @param #number hPa Pressure in hPa.
-- @return #number Pressure in mmHg. -- @return #number Pressure in mmHg.
UTILS.hPa2mmHg = function( hPa ) UTILS.hPa2mmHg = function( hPa )
return hPa * 0.7500615613030 return hPa * 0.7500615613030
end end
--- Convert kilo gramms (kg) to pounds (lbs). --- Convert kilograms (kg) to pounds (lbs).
-- @param #number kg Mass in kg. -- @param #number kg Mass in kg.
-- @return #number Mass in lbs. -- @return #number Mass in lbs.
UTILS.kg2lbs = function( kg ) UTILS.kg2lbs = function( kg )
@ -508,8 +503,7 @@ UTILS.tostringLL = function( lat, lon, acc, DMS)
end end
-- 024° 23' 12"N or 024° 23' 12.03"N -- 024° 23' 12"N or 024° 23' 12.03"N
return string.format('%03d°', latDeg)..string.format('%02d', latMin)..'\''..string.format(secFrmtStr, latSec)..'"'..latHemi..' ' return string.format( '%03d°', latDeg ) .. string.format( '%02d', latMin ) .. '\'' .. string.format( secFrmtStr, latSec ) .. '"' .. latHemi .. ' ' .. string.format( '%03d°', lonDeg ) .. string.format( '%02d', lonMin ) .. '\'' .. string.format( secFrmtStr, lonSec ) .. '"' .. lonHemi
.. string.format('%03d°', lonDeg)..string.format('%02d', lonMin)..'\''..string.format(secFrmtStr, lonSec)..'"'..lonHemi
else -- degrees, decimal minutes. else -- degrees, decimal minutes.
latMin = UTILS.Round( latMin, acc ) latMin = UTILS.Round( latMin, acc )
@ -534,8 +528,7 @@ UTILS.tostringLL = function( lat, lon, acc, DMS)
end end
-- 024 23'N or 024 23.123'N -- 024 23'N or 024 23.123'N
return string.format('%03d°', latDeg) .. ' ' .. string.format(minFrmtStr, latMin) .. '\'' .. latHemi .. ' ' return string.format( '%03d°', latDeg ) .. ' ' .. string.format( minFrmtStr, latMin ) .. '\'' .. latHemi .. ' ' .. string.format( '%03d°', lonDeg ) .. ' ' .. string.format( minFrmtStr, lonMin ) .. '\'' .. lonHemi
.. string.format('%03d°', lonDeg) .. ' ' .. string.format(minFrmtStr, lonMin) .. '\'' .. lonHemi
end end
end end
@ -560,8 +553,12 @@ UTILS.tostringMGRS = function(MGRS, acc) --R2.1
local nN = 5 - string.len( Northing ) local nN = 5 - string.len( Northing )
-- Get leading zeros (if any). -- Get leading zeros (if any).
for i=1,nE do Easting="0"..Easting end for i = 1, nE do
for i=1,nN do Northing="0"..Northing end Easting = "0" .. Easting
end
for i = 1, nN do
Northing = "0" .. Northing
end
-- Return MGRS string. -- Return MGRS string.
return string.format( "%s %s %s %s", MGRS.UTMZone, MGRS.MGRSDigraph, string.sub( Easting, 1, acc ), string.sub( Northing, 1, acc ) ) return string.format( "%s %s %s %s", MGRS.UTMZone, MGRS.MGRSDigraph, string.sub( Easting, 1, acc ), string.sub( Northing, 1, acc ) )
@ -569,7 +566,6 @@ UTILS.tostringMGRS = function(MGRS, acc) --R2.1
end end
--- From http://lua-users.org/wiki/SimpleRound --- From http://lua-users.org/wiki/SimpleRound
-- use negative idp for rounding ahead of decimal place, positive for rounding after decimal place -- use negative idp for rounding ahead of decimal place, positive for rounding after decimal place
function UTILS.Round( num, idp ) function UTILS.Round( num, idp )
@ -591,12 +587,16 @@ end
function UTILS.spairs( t, order ) function UTILS.spairs( t, order )
-- collect the keys -- collect the keys
local keys = {} local keys = {}
for k in pairs(t) do keys[#keys+1] = k end for k in pairs( t ) do
keys[#keys + 1] = k
end
-- if order function given, sort by it by passing the table and keys a, b, -- if order function given, sort by it by passing the table and keys a, b,
-- otherwise just sort the keys -- otherwise just sort the keys
if order then if order then
table.sort(keys, function(a,b) return order(t, a, b) end) table.sort( keys, function( a, b )
return order( t, a, b )
end )
else else
table.sort( keys ) table.sort( keys )
end end
@ -611,18 +611,22 @@ function UTILS.spairs( t, order )
end end
end end
-- Here is a customized version of pairs, which I called kpairs because it iterates over the table in a sorted order, based on a function that will determine the keys as reference first. -- Here is a customized version of pairs, which I called kpairs because it iterates over the table in a sorted order, based on a function that will determine the keys as reference first.
function UTILS.kpairs( t, getkey, order ) function UTILS.kpairs( t, getkey, order )
-- collect the keys -- collect the keys
local keys = {} local keys = {}
local keyso = {} local keyso = {}
for k, o in pairs(t) do keys[#keys+1] = k keyso[#keyso+1] = getkey( o ) end for k, o in pairs( t ) do
keys[#keys + 1] = k
keyso[#keyso + 1] = getkey( o )
end
-- if order function given, sort by it by passing the table and keys a, b, -- if order function given, sort by it by passing the table and keys a, b,
-- otherwise just sort the keys -- otherwise just sort the keys
if order then if order then
table.sort(keys, function(a,b) return order(t, a, b) end) table.sort( keys, function( a, b )
return order( t, a, b )
end )
else else
table.sort( keys ) table.sort( keys )
end end
@ -642,7 +646,9 @@ function UTILS.rpairs( t )
-- collect the keys -- collect the keys
local keys = {} local keys = {}
for k in pairs(t) do keys[#keys+1] = k end for k in pairs( t ) do
keys[#keys + 1] = k
end
local random = {} local random = {}
local j = #keys local j = #keys
@ -681,7 +687,6 @@ function UTILS.RemoveMark(MarkID, Delay)
end end
end end
-- Test if a Vec2 is in a radius of another Vec2 -- Test if a Vec2 is in a radius of another Vec2
function UTILS.IsInRadius( InVec2, Vec2, Radius ) function UTILS.IsInRadius( InVec2, Vec2, Radius )
@ -748,9 +753,9 @@ function UTILS.BeaufortScale(speed)
return bn, bd return bn, bd
end end
--- Split string at seperators. C.f. http://stackoverflow.com/questions/1426954/split-string-in-lua --- Split string at separators. C.f. http://stackoverflow.com/questions/1426954/split-string-in-lua
-- @param #string str Sting to split. -- @param #string str Sting to split.
-- @param #string sep Speparator for split. -- @param #string sep Separator for split.
-- @return #table Split text. -- @return #table Split text.
function UTILS.Split( str, sep ) function UTILS.Split( str, sep )
local result = {} local result = {}
@ -827,7 +832,7 @@ function UTILS.SecondsOfToday()
return UTILS.ClockToSeconds( clock ) return UTILS.ClockToSeconds( clock )
end end
--- Cound seconds until next midnight. --- Count seconds until next midnight.
-- @return #number Seconds to midnight. -- @return #number Seconds to midnight.
function UTILS.SecondsToMidnight() function UTILS.SecondsToMidnight()
return 24 * 60 * 60 - UTILS.SecondsOfToday() return 24 * 60 * 60 - UTILS.SecondsOfToday()
@ -978,7 +983,6 @@ function UTILS.Vec2Dot(a, b)
return a.x * b.x + a.y * b.y return a.x * b.x + a.y * b.y
end end
--- Calculate the [euclidean norm](https://en.wikipedia.org/wiki/Euclidean_distance) (length) of a 3D vector. --- Calculate the [euclidean norm](https://en.wikipedia.org/wiki/Euclidean_distance) (length) of a 3D vector.
-- @param DCS#Vec3 a Vector in 3D with x, y, z components. -- @param DCS#Vec3 a Vector in 3D with x, y, z components.
-- @return #number Norm of the vector. -- @return #number Norm of the vector.
@ -1006,7 +1010,6 @@ function UTILS.VecDist2D(a, b)
return d return d
end end
--- Calculate the distance between two 3D vectors. --- Calculate the distance between two 3D vectors.
-- @param DCS#Vec3 a Vector in 3D with x, y, z components. -- @param DCS#Vec3 a Vector in 3D with x, y, z components.
-- @param DCS#Vec3 b Vector in 3D with x, y, z components. -- @param DCS#Vec3 b Vector in 3D with x, y, z components.
@ -1105,7 +1108,6 @@ function UTILS.HdgDiff(h1, h2)
return math.abs( delta ) return math.abs( delta )
end end
--- Translate 3D vector in the 2D (x,z) plane. y-component (usually altitude) unchanged. --- Translate 3D vector in the 2D (x,z) plane. y-component (usually altitude) unchanged.
-- @param DCS#Vec3 a Vector in 3D with x, y, z components. -- @param DCS#Vec3 a Vector in 3D with x, y, z components.
-- @param #number distance The distance to translate. -- @param #number distance The distance to translate.
@ -1177,7 +1179,6 @@ function UTILS.Vec2Rotate2D(a, angle)
return A return A
end end
--- Converts a TACAN Channel/Mode couple into a frequency in Hz. --- Converts a TACAN Channel/Mode couple into a frequency in Hz.
-- @param #number TACANChannel The TACAN channel, i.e. the 10 in "10X". -- @param #number TACANChannel The TACAN channel, i.e. the 10 in "10X".
-- @param #string TACANMode The TACAN mode, i.e. the "X" in "10X". -- @param #string TACANMode The TACAN mode, i.e. the "X" in "10X".
@ -1214,7 +1215,6 @@ function UTILS.TACANToFrequency(TACANChannel, TACANMode)
return (A + TACANChannel - B) * 1000000 return (A + TACANChannel - B) * 1000000
end end
--- Returns the DCS map/theatre as optained by env.mission.theatre --- Returns the DCS map/theatre as optained by env.mission.theatre
-- @return #string DCS map name. -- @return #string DCS map name.
function UTILS.GetDCSMap() function UTILS.GetDCSMap()
@ -1349,7 +1349,6 @@ function UTILS.CheckMemory(output)
return mem return mem
end end
--- Get the coalition name from its numerical ID, e.g. coaliton.side.RED. --- Get the coalition name from its numerical ID, e.g. coaliton.side.RED.
-- @param #number Coalition The coalition ID. -- @param #number Coalition The coalition ID.
-- @return #string The coalition name, i.e. "Neutral", "Red" or "Blue" (or "Unknown"). -- @return #string The coalition name, i.e. "Neutral", "Red" or "Blue" (or "Unknown").
@ -1449,7 +1448,6 @@ function UTILS.GMTToLocalTimeDifference()
end end
--- Get the day of the year. Counting starts on 1st of January. --- Get the day of the year. Counting starts on 1st of January.
-- @param #number Year The year. -- @param #number Year The year.
-- @param #number Month The month. -- @param #number Month The month.
@ -1483,18 +1481,31 @@ function UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, Rising, Tlocal)
local n = DayOfYear local n = DayOfYear
Tlocal = Tlocal or 0 Tlocal = Tlocal or 0
-- Short cuts. -- Short cuts.
local rad = math.rad local rad = math.rad
local deg = math.deg local deg = math.deg
local floor = math.floor local floor = math.floor
local frac = function(n) return n - floor(n) end local frac = function( n )
local cos = function(d) return math.cos(rad(d)) end return n - floor( n )
local acos = function(d) return deg(math.acos(d)) end end
local sin = function(d) return math.sin(rad(d)) end local cos = function( d )
local asin = function(d) return deg(math.asin(d)) end return math.cos( rad( d ) )
local tan = function(d) return math.tan(rad(d)) end end
local atan = function(d) return deg(math.atan(d)) end local acos = function( d )
return deg( math.acos( d ) )
end
local sin = function( d )
return math.sin( rad( d ) )
end
local asin = function( d )
return deg( math.asin( d ) )
end
local tan = function( d )
return math.tan( rad( d ) )
end
local atan = function( d )
return deg( math.atan( d ) )
end
local function fit_into_range( val, min, max ) local function fit_into_range( val, min, max )
local range = max - min local range = max - min
@ -1823,9 +1834,7 @@ function UTILS.GenerateLaserCodes()
while _code < 1777 and _count < 30 do while _code < 1777 and _count < 30 do
while true do while true do
_code = _code + 1 _code = _code + 1
if not ContainsDigit(_code, 8) if not ContainsDigit( _code, 8 ) and not ContainsDigit( _code, 9 ) and not ContainsDigit( _code, 0 ) then
and not ContainsDigit(_code, 9)
and not ContainsDigit(_code, 0) then
table.insert( jtacGeneratedLaserCodes, _code ) table.insert( jtacGeneratedLaserCodes, _code )
break break
end end
@ -2092,7 +2101,9 @@ end
-- @return #table Table of data objects (tables) containing groupname, coordinate and group object. Returns nil when file cannot be read. -- @return #table Table of data objects (tables) containing groupname, coordinate and group object. Returns nil when file cannot be read.
function UTILS.LoadStationaryListOfGroups( Path, Filename, Reduce ) function UTILS.LoadStationaryListOfGroups( Path, Filename, Reduce )
local reduce = true local reduce = true
if Reduce == false then reduce = false end if Reduce == false then
reduce = false
end
local filename = Filename or "StateListofGroups" local filename = Filename or "StateListofGroups"
local datatable = {} local datatable = {}
if UTILS.CheckFileExists( Path, filename ) then if UTILS.CheckFileExists( Path, filename ) then
@ -2139,7 +2150,9 @@ end
-- Returns nil when file cannot be read. Returns a table of data entries if Spawn is false: `{ groupname=groupname, size=size, coordinate=coordinate }` -- Returns nil when file cannot be read. Returns a table of data entries if Spawn is false: `{ groupname=groupname, size=size, coordinate=coordinate }`
function UTILS.LoadSetOfGroups( Path, Filename, Spawn ) function UTILS.LoadSetOfGroups( Path, Filename, Spawn )
local spawn = true local spawn = true
if Spawn == false then spawn = false end if Spawn == false then
spawn = false
end
BASE:I( "Spawn = " .. tostring( spawn ) ) BASE:I( "Spawn = " .. tostring( spawn ) )
local filename = Filename or "SetOfGroups" local filename = Filename or "SetOfGroups"
local setdata = SET_GROUP:New() local setdata = SET_GROUP:New()
@ -2162,10 +2175,7 @@ function UTILS.LoadSetOfGroups(Path,Filename,Spawn)
local data = { groupname = groupname, size = size, coordinate = coordinate } local data = { groupname = groupname, size = size, coordinate = coordinate }
table.insert( datatable, data ) table.insert( datatable, data )
if spawn then if spawn then
local group = SPAWN:New(groupname) local group = SPAWN:New( groupname ):InitDelayOff():OnSpawnGroup( function( spwndgrp )
:InitDelayOff()
:OnSpawnGroup(
function(spwndgrp)
setdata:AddObject( spwndgrp ) setdata:AddObject( spwndgrp )
local actualsize = spwndgrp:CountAliveUnits() local actualsize = spwndgrp:CountAliveUnits()
if actualsize > size then if actualsize > size then
@ -2177,9 +2187,7 @@ function UTILS.LoadSetOfGroups(Path,Filename,Spawn)
units2[i]:Destroy( false ) units2[i]:Destroy( false )
end end
end end
end end ):SpawnFromCoordinate( coordinate )
)
:SpawnFromCoordinate(coordinate)
end end
end end
else else
@ -2227,7 +2235,9 @@ end
-- Returns nil when file cannot be read. -- Returns nil when file cannot be read.
function UTILS.LoadStationaryListOfStatics( Path, Filename, Reduce ) function UTILS.LoadStationaryListOfStatics( Path, Filename, Reduce )
local reduce = true local reduce = true
if Reduce == false then reduce = false end if Reduce == false then
reduce = false
end
local filename = Filename or "StateListofStatics" local filename = Filename or "StateListofStatics"
local datatable = {} local datatable = {}
if UTILS.CheckFileExists( Path, filename ) then if UTILS.CheckFileExists( Path, filename ) then