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
column_table_limit: 500
table_sep: ','
extra_sep_at_table_end: false
extra_sep_at_table_end: true
break_after_operator: true
single_quote_to_double_quote: true
single_quote_to_double_quote: false
double_quote_to_single_quote: false
spaces_before_call: 1
spaces_inside_functiondef_parens: true

View File

@ -33,15 +33,11 @@
-- @module Core.Point
-- @image Core_Coordinate.JPG
do -- COORDINATE
--- @type COORDINATE
-- @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.
--
-- # 1) Create a COORDINATE object.
@ -52,7 +48,6 @@ do -- COORDINATE
-- * @{#COORDINATE.NewFromVec2}(): from a @{DCS#Vec2} and possible altitude.
-- * @{#COORDINATE.NewFromVec3}(): from a @{DCS#Vec3}.
--
--
-- # 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:
@ -82,7 +77,6 @@ do -- COORDINATE
--
-- * @{#COORDINATE.IlluminationBomb}(): To illuminate the point.
--
--
-- # 3) Create markings on the map.
--
-- 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.
--
-- 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.
-- The method @{#COORDINATE.IsLOS}() returns if the two coodinates have LOS.
-- 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 coordinates have LOS.
--
-- ## 4.7) Check the coordinate position.
--
@ -139,8 +133,6 @@ do -- COORDINATE
-- * @{#COORDINATE.IsInSphere}(): is in a given sphere.
-- * @{#COORDINATE.IsAtCoordinate2D}(): is in a given coordinate within a specific precision.
--
--
--
-- # 5) Measure the simulation environment at the coordinate.
--
-- ## 5.1) Weather specific.
@ -185,7 +177,7 @@ do -- COORDINATE
-- ## 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.ToStringLL}(): Generates a Latutude & Longutude text.
-- * @{#COORDINATE.ToStringLL}(): Generates a Latitude & Longitude text.
--
-- ## 10) Drawings on F10 map
--
@ -228,7 +220,6 @@ do -- COORDINATE
LandingReFuAr = "LandingReFuAr",
}
--- COORDINATE constructor.
-- @param #COORDINATE self
-- @param DCS#Distance x The x coordinate of the Vec3 point, pointing to the North.
@ -293,7 +284,6 @@ do -- COORDINATE
return self
end
--- Return the coordinates of the COORDINATE in Vec3 format.
-- @param #COORDINATE self
-- @return DCS#Vec3 The Vec3 format coordinate.
@ -301,7 +291,6 @@ do -- COORDINATE
return { x = self.x, y = self.y, z = self.z }
end
--- Return the coordinates of the COORDINATE in Vec2 format.
-- @param #COORDINATE self
-- @return DCS#Vec2 The Vec2 format coordinate.
@ -406,7 +395,7 @@ do -- COORDINATE
id = world.VolumeType.SPHERE,
params = {
point = self:GetVec3(),
radius = radius,
radius = radius
}
}
@ -530,7 +519,6 @@ do -- COORDINATE
return umin
end
--- Calculate the distance from a reference @{#COORDINATE}.
-- @param #COORDINATE self
-- @param #COORDINATE PointVec2Reference The reference @{#COORDINATE}.
@ -629,7 +617,6 @@ do -- COORDINATE
return RandomVec2
end
--- Return a random Coordinate within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE.
-- @param #COORDINATE self
-- @param DCS#Distance OuterRadius Outer radius in meters.
@ -641,7 +628,6 @@ do -- COORDINATE
return COORDINATE:NewFromVec2( self:GetRandomVec2InRadius( OuterRadius, InnerRadius ) )
end
--- Return a random Vec3 within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE.
-- @param #COORDINATE self
-- @param DCS#Distance OuterRadius
@ -664,14 +650,12 @@ do -- COORDINATE
return land.getHeight( Vec2 )
end
--- Set the heading of the coordinate, if applicable.
-- @param #COORDINATE self
function COORDINATE:SetHeading( Heading )
self.Heading = Heading
end
--- Get the heading of the coordinate, if applicable.
-- @param #COORDINATE self
-- @return #number or nil
@ -679,7 +663,6 @@ do -- COORDINATE
return self.Heading
end
--- Set the velocity of the COORDINATE.
-- @param #COORDINATE self
-- @param #string Velocity Velocity in meters per second.
@ -687,7 +670,6 @@ do -- COORDINATE
self.Velocity = Velocity
end
--- Return the velocity of the COORDINATE.
-- @param #COORDINATE self
-- @return #number Velocity in meters per second.
@ -696,7 +678,6 @@ do -- COORDINATE
return Velocity or 0
end
--- Return velocity text of the COORDINATE.
-- @param #COORDINATE self
-- @return #string
@ -705,8 +686,7 @@ do -- COORDINATE
return self:GetVelocityText( Settings ) .. ", " .. self:GetHeadingText( Settings )
end
--- Return a direction vector Vec3 from COORDINATE to the COORDINATE.
--- Return a direction vector Vec3 from this COORDINATE to the target COORDINATE.
-- @param #COORDINATE self
-- @param #COORDINATE TargetCoordinate The target COORDINATE.
-- @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 }
end
--- Get a correction in radians of the real magnetic north of the COORDINATE.
-- @param #COORDINATE self
-- @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 )
end
--- Return an angle in radians from the COORDINATE using a direction vector in Vec3 format.
-- @param #COORDINATE self
-- @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}.
-- The text will reflect the temperature like this:
--
-- - For Russian and European aircraft using the metric system - Degrees Celcius (°C)
-- - For Americain aircraft we link to the imperial system - Degrees Farenheit (°F)
-- - For Russian and European aircraft using the metric system - Degrees Celsius (°C)
-- - For American aircraft we link to the imperial system - Degrees Fahrenheit (°F)
--
-- A text containing a pressure will look like this:
--
@ -817,15 +795,15 @@ do -- COORDINATE
-- @return #string Temperature according the measurement system @{Settings}.
function COORDINATE:GetTemperatureText( height, Settings )
local DegreesCelcius = self:GetTemperature( height )
local DegreesCelsius = self:GetTemperature( height )
local Settings = Settings or _SETTINGS
if DegreesCelcius then
if DegreesCelsius then
if Settings:IsMetric() then
return string.format( " %-2.2f °C", DegreesCelcius )
return string.format( " %-2.2f °C", DegreesCelsius )
else
return string.format( " %-2.2f °F", UTILS.CelciusToFarenheit( DegreesCelcius ) )
return string.format( " %-2.2f °F", UTILS.CelsiusToFahrenheit( DegreesCelsius ) )
end
else
return " no temperature"
@ -834,7 +812,6 @@ do -- COORDINATE
return nil
end
--- Returns the pressure in hPa.
-- @param #COORDINATE self
-- @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}.
-- The text will contain always the pressure in hPa and:
--
-- - 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 Russian and European aircraft using the metric system - hPa and mmHg.
-- - For American and European aircraft we link to the imperial system - hPa and inHg.
--
-- A text containing a pressure will look like this:
--
@ -882,7 +859,7 @@ do -- COORDINATE
return nil
end
--- Returns the heading from this to another coordinate.
--- Returns the heading from this to another COORDINATE.
-- @param #COORDINATE self
-- @param #COORDINATE ToCoordinate
-- @return #number Heading in degrees.
@ -939,12 +916,11 @@ do -- COORDINATE
return vec3
end
--- Returns a text documenting the wind direction (from) and strength according the measurement system @{Settings}.
-- 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 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:
--
@ -983,10 +959,9 @@ do -- COORDINATE
return ((TargetVec3.x - SourceVec3.x) ^ 2 + (TargetVec3.y - SourceVec3.y) ^ 2 + (TargetVec3.z - SourceVec3.z) ^ 2) ^ 0.5
end
--- Provides a bearing text in degrees.
-- @param #COORDINATE self
-- @param #number AngleRadians The angle in randians.
-- @param #number AngleRadians The angle in radians.
-- @param #number Precision The precision.
-- @param Core.Settings#SETTINGS Settings
-- @return #string The bearing text in degrees.
@ -1057,8 +1032,6 @@ do -- COORDINATE
end
end
--- Return the velocity text of the COORDINATE.
-- @param #COORDINATE self
-- @return #string Velocity text.
@ -1076,7 +1049,6 @@ do -- COORDINATE
end
end
--- Return the heading text of the COORDINATE.
-- @param #COORDINATE self
-- @return #string Heading text.
@ -1089,10 +1061,9 @@ do -- COORDINATE
end
end
--- Provides a Bearing / Range string
-- @param #COORDINATE self
-- @param #number AngleRadians The angle in randians
-- @param #number AngleRadians The angle in radians
-- @param #number Distance The distance
-- @param Core.Settings#SETTINGS Settings
-- @return #string The BR Text
@ -1110,7 +1081,7 @@ do -- COORDINATE
--- Provides a Bearing / Range / Altitude string
-- @param #COORDINATE self
-- @param #number AngleRadians The angle in randians
-- @param #number AngleRadians The angle in radians
-- @param #number Distance The distance
-- @param Core.Settings#SETTINGS Settings
-- @return #string The BRA Text
@ -1127,7 +1098,6 @@ do -- COORDINATE
return BRAText
end
--- Set altitude.
-- @param #COORDINATE self
-- @param #number altitude New altitude in meters.
@ -1233,7 +1203,6 @@ do -- COORDINATE
return RoutePoint
end
--- Build a Waypoint Air "Turning Point".
-- @param #COORDINATE self
-- @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 )
end
--- Build a Waypoint Air "Fly Over Point".
-- @param #COORDINATE self
-- @param #COORDINATE.WaypointAltType AltType The altitude type.
@ -1255,7 +1223,6 @@ do -- COORDINATE
return self:WaypointAir( AltType, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.FlyoverPoint, Speed )
end
--- Build a Waypoint Air "Take Off Parking Hot".
-- @param #COORDINATE self
-- @param #COORDINATE.WaypointAltType AltType The altitude type.
@ -1265,7 +1232,6 @@ do -- COORDINATE
return self:WaypointAir( AltType, COORDINATE.WaypointType.TakeOffParkingHot, COORDINATE.WaypointAction.FromParkingAreaHot, Speed )
end
--- Build a Waypoint Air "Take Off Parking".
-- @param #COORDINATE self
-- @param #COORDINATE.WaypointAltType AltType The altitude type.
@ -1275,7 +1241,6 @@ do -- COORDINATE
return self:WaypointAir( AltType, COORDINATE.WaypointType.TakeOffParking, COORDINATE.WaypointAction.FromParkingArea, Speed )
end
--- Build a Waypoint Air "Take Off Runway".
-- @param #COORDINATE self
-- @param #COORDINATE.WaypointAltType AltType The altitude type.
@ -1285,7 +1250,6 @@ do -- COORDINATE
return self:WaypointAir( AltType, COORDINATE.WaypointType.TakeOff, COORDINATE.WaypointAction.FromRunway, Speed )
end
--- Build a Waypoint Air "Landing".
-- @param #COORDINATE self
-- @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 )
end
--- Build an ground type route point.
-- @param #COORDINATE self
-- @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.
-- @param #COORDINATE self
-- @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.
-- @return Core.Point#COORDINATE Coordinate of the nearest parking spot.
-- @return #number Terminal ID.
@ -1554,7 +1517,6 @@ do -- COORDINATE
return COORDINATE:NewFromVec2( vec2 )
end
--- 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.
-- 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 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 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 #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.
@ -1664,7 +1626,6 @@ do -- COORDINATE
return self:GetSurfaceType() == land.SurfaceType.LAND
end
--- Checks if the surface type is road.
-- @param #COORDINATE self
-- @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
end
--- Creates an explosion at the point of a certain intensity.
-- @param #COORDINATE self
-- @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 )
end
--- Smokes the point in a color.
-- @param #COORDINATE self
-- @param Utilities.Utils#SMOKECOLOR SmokeColor
@ -1989,7 +1948,7 @@ do -- COORDINATE
--- Line to all.
-- Creates a line on the F10 map from one point to another.
-- @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 #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
-- @param #number Alpha Transparency [0,1]. Default 1.
@ -2014,7 +1973,7 @@ do -- COORDINATE
--- Circle to all.
-- Creates a circle on the map with a given radius, color, fill color, and outline.
-- @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 #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
-- @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.
-- Creates a line on the F10 map from one point to another.
-- @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 #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
-- @param #number Alpha Transparency [0,1]. Default 1.
@ -2244,7 +2203,6 @@ do -- COORDINATE
return IsLOS
end
--- 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 Coordinate The coordinate that will be tested if it is in the radius of this coordinate.
@ -2260,7 +2218,6 @@ do -- COORDINATE
return InRadius
end
--- 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.
-- @param #COORDINATE self
@ -2567,7 +2524,6 @@ do -- COORDINATE
return delta / 60
end
--- Return a BR string from a COORDINATE to the COORDINATE.
-- @param #COORDINATE self
-- @param #COORDINATE FromCoordinate The coordinate to measure the distance and the bearing from.
@ -2743,7 +2699,6 @@ do -- COORDINATE
end
--- Provides a coordinate string of the point, based on the A2A coordinate format system.
-- @param #COORDINATE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
@ -2814,7 +2769,6 @@ do -- COORDINATE
end
end
if ModeA2A == nil then
local IsAir = Controllable and (Controllable:IsAirPlane() or Controllable:IsHelicopter()) or false
if IsAir then
@ -2824,7 +2778,6 @@ do -- COORDINATE
end
end
if ModeA2A == true then
return self:ToStringA2A( Controllable, Settings )
else
@ -2899,7 +2852,6 @@ do -- POINT_VEC3
-- @field #POINT_VEC3.RoutePointAction RoutePointAction
-- @extends #COORDINATE
--- 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.
@ -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,
-- who you can find on the Eagle Dynamics Forums.
--
--
-- ## POINT_VEC3 constructor
--
-- A new POINT_VEC3 object can be created with:
@ -2929,19 +2880,16 @@ do -- POINT_VEC3
--
-- local Vec3 = PointVec3:AddX( 100 ):AddZ( 150 ):GetVec3()
--
--
-- ## 3D calculation methods
--
-- Various calculation methods exist to use or manipulate 3D space. Find below a short description of each method:
--
--
-- ## Point Randomization
--
-- 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.
--
--
-- @field #POINT_VEC3
POINT_VEC3 = {
ClassName = "POINT_VEC3",
@ -3136,8 +3084,6 @@ do -- POINT_VEC2
ClassName = "POINT_VEC2",
}
--- POINT_VEC2 constructor.
-- @param #POINT_VEC2 self
-- @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.
-- @return #POINT_VEC2
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
end
--- 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 DCS#Distance OuterRadius
@ -3321,4 +3266,3 @@ do -- POINT_VEC2
end

View File

@ -742,7 +742,7 @@ function PSEUDOATC:ReportWeather(GID, UID, position, location)
local T=position:GetTemperature()
-- 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
_T=string.format('%d°C', T)
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.
-- GoldwaterRange:AddBombingTargets(bombtargets, 50)
--
-- -- Start range.
-- -- Start Range.
-- 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.
@ -329,7 +329,7 @@ RANGE = {
instructor = nil,
rangecontrolfreq = nil,
rangecontrol = nil,
soundpath = "Range Soundfiles/"
soundpath = "Range Soundfiles/",
}
--- Default range parameters.
@ -345,7 +345,7 @@ RANGE.Defaults = {
boxlength = 3000, -- meters
boxwidth = 300, -- meters
goodpass = 20, -- targethits per pass
foulline = 610 -- meters
foulline = 610, -- meters
}
--- Target type, i.e. unit, static, or coordinate.
@ -500,7 +500,7 @@ RANGE.Sound = {
IRDecimal = { filename = "IR-Decimal.ogg", duration = 0.54 },
IRMegaHertz = { filename = "IR-MegaHertz.ogg", duration = 0.87 },
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.
@ -1089,7 +1089,7 @@ end
--- Set sound files folder within miz file.
-- @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
function RANGE:SetSoundfilesPath( path )
self.soundpath = tostring( path or "Range Soundfiles/" )
@ -1384,12 +1384,14 @@ end
--
-- -- Setup a Range
-- RangeOne = RANGE:New( "Range One" )
-- -- Find the STATIC target object as setup in the ME
-- 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)
-- -- Find the STATIC target object as setup in the ME.
-- 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).
-- 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() )
-- -- Start Range.
-- RangeOne:Start()
--
function RANGE:AddBombingTargetCoordinate( coord, name, goodhitrange )
@ -1436,6 +1438,17 @@ end
-- @param #string namepit Name of the strafe pit target object.
-- @param #string namefoulline Name of the foul line distance marker object.
-- @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 )
self:F( { namepit = namepit, namefoulline = namefoulline } )
@ -2107,7 +2120,7 @@ function RANGE:onafterSave( From, Event, To )
_savefile( filename, scores )
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 #string From From state.
-- @param #string Event Event.
@ -2654,7 +2667,7 @@ function RANGE:_DisplayRangeWeather( _unitname )
local tW = string.format( "%.1f m/s", Ws )
local tP = string.format( "%.1f mmHg", P * hPa2mmHg )
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 ) )
tP = string.format( "%.2f inHg", P * hPa2inHg )
end

View File

@ -1601,7 +1601,7 @@ WAREHOUSE = {
-- @field #number range Range of the unit in meters.
-- @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 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 #WAREHOUSE.Attribute attribute Generalized attribute of the 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 #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 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 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.
@ -239,7 +239,7 @@
--
-- 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
--
@ -1459,8 +1459,8 @@ function ATIS:onafterBroadcast(From, Event, To)
-- Convert to °F.
if self.TDegF then
temperature=UTILS.CelciusToFarenheit(temperature)
dewpoint=UTILS.CelciusToFarenheit(dewpoint)
temperature=UTILS.CelsiusToFahrenheit(temperature)
dewpoint=UTILS.CelsiusToFahrenheit(dewpoint)
end
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, "inHg", "inches 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")
-- Replace ";" by "."

View File

@ -3,9 +3,11 @@
--
-- @module Utils.STTS
-- @image MOOSE.JPG
--- [DCS Enum world](https://wiki.hoggitworld.com/view/DCS_enum_world)
-- @type STTS
-- @field #string DIRECTORY Path of the SRS directory.
--- Simple Text-To-Speech
--
-- Version 0.4 - Compatible with SRS version 1.9.6.0+
@ -40,7 +42,7 @@
-- * OPTIONAL - Speed -10 to +10
-- * OPTIONAL - Gender male, female or neuter
-- * 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
--
--
@ -89,7 +91,7 @@ STTS.SRS_PORT = 5002
--- Google credentials file
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"
--- Function for UUID.
@ -117,11 +119,11 @@ function STTS.round( x, n )
end
--- 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
--
-- 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
--

View File

@ -11,7 +11,6 @@
-- @module Utils
-- @image MOOSE.JPG
--- @type SMOKECOLOR
-- @field Green
-- @field Red
@ -58,10 +57,9 @@ DCSMAP = {
PersianGulf = "PersianGulf",
TheChannel = "TheChannel",
Syria = "Syria",
MarianaIslands="MarianaIslands"
MarianaIslands = "MarianaIslands",
}
--- See [DCS_enum_callsigns](https://wiki.hoggitworld.com/view/DCS_enum_callsigns)
-- @type CALLSIGN
CALLSIGN = {
@ -201,7 +199,6 @@ UTILS.IsInstanceOf = function( object, className )
return false
end
--- Deep copy a table. See http://lua-users.org/wiki/CopyTable
-- @param #table object The input table.
-- @return #table Copy of the input table.
@ -233,7 +230,6 @@ UTILS.DeepCopy = function(object)
return objectreturn
end
--- Porting in Slmod's serialize_slmod2.
-- @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
@ -326,7 +322,6 @@ UTILS.BasicSerialize = function(s)
end
end
UTILS.ToDegree = function( angle )
return angle * 180 / math.pi
end
@ -412,21 +407,21 @@ UTILS.KnotsToMps = function( knots )
return knots / 1.94384 -- * 1852 / 3600
end
--- Convert temperature from Celsius to Farenheit.
-- @param #number Celcius Temperature in degrees Celsius.
-- @return #number Temperature in degrees Farenheit.
UTILS.CelciusToFarenheit = function( Celcius )
return Celcius * 9/5 + 32
--- Convert temperature from Celsius to Fahrenheit.
-- @param #number Celsius Temperature in degrees Celsius.
-- @return #number Temperature in degrees Fahrenheit.
UTILS.CelsiusToFahrenheit = function( Celsius )
return Celsius * 9 / 5 + 32
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.
-- @return #number Pressure in inHg.
UTILS.hPa2inHg = function( hPa )
return hPa * 0.0295299830714
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 altitude Altitude in feet
-- @return #number Corrected KIAS
@ -434,14 +429,14 @@ UTILS.KnotsToAltKIAS = function( knots, altitude )
return (knots * 0.018 * (altitude / 1000)) + knots
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.
-- @return #number Pressure in mmHg.
UTILS.hPa2mmHg = function( hPa )
return hPa * 0.7500615613030
end
--- Convert kilo gramms (kg) to pounds (lbs).
--- Convert kilograms (kg) to pounds (lbs).
-- @param #number kg Mass in kg.
-- @return #number Mass in lbs.
UTILS.kg2lbs = function( kg )
@ -508,8 +503,7 @@ UTILS.tostringLL = function( lat, lon, acc, DMS)
end
-- 024° 23' 12"N or 024° 23' 12.03"N
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
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
else -- degrees, decimal minutes.
latMin = UTILS.Round( latMin, acc )
@ -534,8 +528,7 @@ UTILS.tostringLL = function( lat, lon, acc, DMS)
end
-- 024 23'N or 024 23.123'N
return string.format('%03d°', latDeg) .. ' ' .. string.format(minFrmtStr, latMin) .. '\'' .. latHemi .. ' '
.. string.format('%03d°', lonDeg) .. ' ' .. string.format(minFrmtStr, lonMin) .. '\'' .. lonHemi
return string.format( '%03d°', latDeg ) .. ' ' .. string.format( minFrmtStr, latMin ) .. '\'' .. latHemi .. ' ' .. string.format( '%03d°', lonDeg ) .. ' ' .. string.format( minFrmtStr, lonMin ) .. '\'' .. lonHemi
end
end
@ -560,8 +553,12 @@ UTILS.tostringMGRS = function(MGRS, acc) --R2.1
local nN = 5 - string.len( Northing )
-- Get leading zeros (if any).
for i=1,nE do Easting="0"..Easting end
for i=1,nN do Northing="0"..Northing end
for i = 1, nE do
Easting = "0" .. Easting
end
for i = 1, nN do
Northing = "0" .. Northing
end
-- Return MGRS string.
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
--- From http://lua-users.org/wiki/SimpleRound
-- use negative idp for rounding ahead of decimal place, positive for rounding after decimal place
function UTILS.Round( num, idp )
@ -591,12 +587,16 @@ end
function UTILS.spairs( t, order )
-- collect the 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,
-- otherwise just sort the keys
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
table.sort( keys )
end
@ -611,18 +611,22 @@ function UTILS.spairs( t, order )
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.
function UTILS.kpairs( t, getkey, order )
-- collect the keys
local keys = {}
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,
-- otherwise just sort the keys
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
table.sort( keys )
end
@ -642,7 +646,9 @@ function UTILS.rpairs( t )
-- collect the 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 j = #keys
@ -681,7 +687,6 @@ function UTILS.RemoveMark(MarkID, Delay)
end
end
-- Test if a Vec2 is in a radius of another Vec2
function UTILS.IsInRadius( InVec2, Vec2, Radius )
@ -748,9 +753,9 @@ function UTILS.BeaufortScale(speed)
return bn, bd
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 sep Speparator for split.
-- @param #string sep Separator for split.
-- @return #table Split text.
function UTILS.Split( str, sep )
local result = {}
@ -827,7 +832,7 @@ function UTILS.SecondsOfToday()
return UTILS.ClockToSeconds( clock )
end
--- Cound seconds until next midnight.
--- Count seconds until next midnight.
-- @return #number Seconds to midnight.
function UTILS.SecondsToMidnight()
return 24 * 60 * 60 - UTILS.SecondsOfToday()
@ -978,7 +983,6 @@ function UTILS.Vec2Dot(a, b)
return a.x * b.x + a.y * b.y
end
--- 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.
-- @return #number Norm of the vector.
@ -1006,7 +1010,6 @@ function UTILS.VecDist2D(a, b)
return d
end
--- Calculate the distance between two 3D vectors.
-- @param DCS#Vec3 a 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 )
end
--- 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 #number distance The distance to translate.
@ -1177,7 +1179,6 @@ function UTILS.Vec2Rotate2D(a, angle)
return A
end
--- Converts a TACAN Channel/Mode couple into a frequency in Hz.
-- @param #number TACANChannel The TACAN channel, i.e. the 10 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
end
--- Returns the DCS map/theatre as optained by env.mission.theatre
-- @return #string DCS map name.
function UTILS.GetDCSMap()
@ -1349,7 +1349,6 @@ function UTILS.CheckMemory(output)
return mem
end
--- Get the coalition name from its numerical ID, e.g. coaliton.side.RED.
-- @param #number Coalition The coalition ID.
-- @return #string The coalition name, i.e. "Neutral", "Red" or "Blue" (or "Unknown").
@ -1449,7 +1448,6 @@ function UTILS.GMTToLocalTimeDifference()
end
--- Get the day of the year. Counting starts on 1st of January.
-- @param #number Year The year.
-- @param #number Month The month.
@ -1483,18 +1481,31 @@ function UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, Rising, Tlocal)
local n = DayOfYear
Tlocal = Tlocal or 0
-- Short cuts.
local rad = math.rad
local deg = math.deg
local floor = math.floor
local frac = function(n) return n - floor(n) end
local cos = function(d) return math.cos(rad(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 frac = function( n )
return n - floor( n )
end
local cos = function( d )
return math.cos( rad( 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 range = max - min
@ -1823,9 +1834,7 @@ function UTILS.GenerateLaserCodes()
while _code < 1777 and _count < 30 do
while true do
_code = _code + 1
if not ContainsDigit(_code, 8)
and not ContainsDigit(_code, 9)
and not ContainsDigit(_code, 0) then
if not ContainsDigit( _code, 8 ) and not ContainsDigit( _code, 9 ) and not ContainsDigit( _code, 0 ) then
table.insert( jtacGeneratedLaserCodes, _code )
break
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.
function UTILS.LoadStationaryListOfGroups( Path, Filename, Reduce )
local reduce = true
if Reduce == false then reduce = false end
if Reduce == false then
reduce = false
end
local filename = Filename or "StateListofGroups"
local datatable = {}
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 }`
function UTILS.LoadSetOfGroups( Path, Filename, Spawn )
local spawn = true
if Spawn == false then spawn = false end
if Spawn == false then
spawn = false
end
BASE:I( "Spawn = " .. tostring( spawn ) )
local filename = Filename or "SetOfGroups"
local setdata = SET_GROUP:New()
@ -2162,10 +2175,7 @@ function UTILS.LoadSetOfGroups(Path,Filename,Spawn)
local data = { groupname = groupname, size = size, coordinate = coordinate }
table.insert( datatable, data )
if spawn then
local group = SPAWN:New(groupname)
:InitDelayOff()
:OnSpawnGroup(
function(spwndgrp)
local group = SPAWN:New( groupname ):InitDelayOff():OnSpawnGroup( function( spwndgrp )
setdata:AddObject( spwndgrp )
local actualsize = spwndgrp:CountAliveUnits()
if actualsize > size then
@ -2177,9 +2187,7 @@ function UTILS.LoadSetOfGroups(Path,Filename,Spawn)
units2[i]:Destroy( false )
end
end
end
)
:SpawnFromCoordinate(coordinate)
end ):SpawnFromCoordinate( coordinate )
end
end
else
@ -2227,7 +2235,9 @@ end
-- Returns nil when file cannot be read.
function UTILS.LoadStationaryListOfStatics( Path, Filename, Reduce )
local reduce = true
if Reduce == false then reduce = false end
if Reduce == false then
reduce = false
end
local filename = Filename or "StateListofStatics"
local datatable = {}
if UTILS.CheckFileExists( Path, filename ) then