mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Correcting Celcius to Celsius
This commit is contained in:
parent
ca8b0899d0
commit
0213bc7aef
@ -932,7 +932,7 @@ do -- COORDINATE
|
|||||||
if Settings:IsMetric() then
|
if Settings:IsMetric() then
|
||||||
return string.format( " %-2.2f °C", DegreesCelcius )
|
return string.format( " %-2.2f °C", DegreesCelcius )
|
||||||
else
|
else
|
||||||
return string.format( " %-2.2f °F", UTILS.CelciusToFarenheit( DegreesCelcius ) )
|
return string.format( " %-2.2f °F", UTILS.CelsiusToFarenheit( DegreesCelcius ) )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return " no temperature"
|
return " no temperature"
|
||||||
|
|||||||
@ -2755,7 +2755,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.CelsiusToFarenheit(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
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
-- @module Utils
|
-- @module Utils
|
||||||
-- @image MOOSE.JPG
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
|
|
||||||
--- @type SMOKECOLOR
|
--- @type SMOKECOLOR
|
||||||
-- @field Green
|
-- @field Green
|
||||||
-- @field Red
|
-- @field Red
|
||||||
@ -58,9 +59,10 @@ 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={
|
||||||
@ -256,6 +258,7 @@ 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.
|
||||||
@ -287,6 +290,7 @@ 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
|
||||||
@ -379,6 +383,7 @@ 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
|
||||||
@ -468,21 +473,21 @@ UTILS.KnotsToMps = function( knots )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Convert temperature from Celsius to Fahrenheit.
|
--- Convert temperature from Celsius to Farenheit.
|
||||||
-- @param #number Celsius Temperature in degrees Celsius.
|
-- @param #number Celcius Temperature in degrees Celsius.
|
||||||
-- @return #number Temperature in degrees Fahrenheit.
|
-- @return #number Temperature in degrees Farenheit.
|
||||||
UTILS.CelsiusToFahrenheit = function( Celsius )
|
UTILS.CelsiusToFarenheit = function( Celcius )
|
||||||
return Celsius * 9 / 5 + 32
|
return Celcius * 9/5 + 32
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Convert pressure from hectopascal (hPa) to inches of mercury (inHg).
|
--- Convert pressure from hecto Pascal (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 altitude corrected KIAS, e.g. for tankers.
|
--- Convert knots to alitude 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
|
||||||
@ -490,14 +495,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 hectopascal (hPa) to millimeters of mercury (mmHg).
|
--- Convert pressure from hecto Pascal (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 kilograms (kg) to pounds (lbs).
|
--- Convert kilo gramms (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 )
|
||||||
@ -564,7 +569,8 @@ 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 .. ' ' .. 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.
|
else -- degrees, decimal minutes.
|
||||||
latMin = UTILS.Round(latMin, acc)
|
latMin = UTILS.Round(latMin, acc)
|
||||||
@ -589,7 +595,8 @@ 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 .. ' ' .. 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
|
||||||
end
|
end
|
||||||
@ -614,12 +621,8 @@ 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
|
for i=1,nE do Easting="0"..Easting end
|
||||||
Easting = "0" .. Easting
|
for i=1,nN do Northing="0"..Northing end
|
||||||
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))
|
||||||
@ -627,6 +630,7 @@ 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 )
|
||||||
@ -648,16 +652,12 @@ 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
|
for k in pairs(t) do keys[#keys+1] = k end
|
||||||
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 )
|
table.sort(keys, function(a,b) return order(t, a, b) end)
|
||||||
return order( t, a, b )
|
|
||||||
end )
|
|
||||||
else
|
else
|
||||||
table.sort(keys)
|
table.sort(keys)
|
||||||
end
|
end
|
||||||
@ -672,22 +672,18 @@ 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
|
for k, o in pairs(t) do keys[#keys+1] = k keyso[#keyso+1] = getkey( o ) end
|
||||||
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 )
|
table.sort(keys, function(a,b) return order(t, a, b) end)
|
||||||
return order( t, a, b )
|
|
||||||
end )
|
|
||||||
else
|
else
|
||||||
table.sort(keys)
|
table.sort(keys)
|
||||||
end
|
end
|
||||||
@ -707,9 +703,7 @@ function UTILS.rpairs( t )
|
|||||||
-- collect the keys
|
-- collect the keys
|
||||||
|
|
||||||
local keys = {}
|
local keys = {}
|
||||||
for k in pairs( t ) do
|
for k in pairs(t) do keys[#keys+1] = k end
|
||||||
keys[#keys + 1] = k
|
|
||||||
end
|
|
||||||
|
|
||||||
local random = {}
|
local random = {}
|
||||||
local j = #keys
|
local j = #keys
|
||||||
@ -748,6 +742,7 @@ 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 )
|
||||||
|
|
||||||
@ -814,9 +809,9 @@ function UTILS.BeaufortScale( speed )
|
|||||||
return bn,bd
|
return bn,bd
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Split string at separators. C.f. http://stackoverflow.com/questions/1426954/split-string-in-lua
|
--- Split string at seperators. 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 Separator for split.
|
-- @param #string sep Speparator for split.
|
||||||
-- @return #table Split text.
|
-- @return #table Split text.
|
||||||
function UTILS.Split(str, sep)
|
function UTILS.Split(str, sep)
|
||||||
local result = {}
|
local result = {}
|
||||||
@ -893,7 +888,7 @@ function UTILS.SecondsOfToday()
|
|||||||
return UTILS.ClockToSeconds(clock)
|
return UTILS.ClockToSeconds(clock)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Count seconds until next midnight.
|
--- Cound 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()
|
||||||
@ -1044,6 +1039,7 @@ 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.
|
||||||
@ -1071,6 +1067,7 @@ 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.
|
||||||
@ -1100,6 +1097,14 @@ function UTILS.VecSubstract( a, b )
|
|||||||
return {x=a.x-b.x, y=a.y-b.y, z=a.z-b.z}
|
return {x=a.x-b.x, y=a.y-b.y, z=a.z-b.z}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Calculate the difference between two 2D vectors by substracting the x,y components from each other.
|
||||||
|
-- @param DCS#Vec2 a Vector in 2D with x, y components.
|
||||||
|
-- @param DCS#Vec2 b Vector in 2D with x, y components.
|
||||||
|
-- @return DCS#Vec2 Vector c=a-b with c(i)=a(i)-b(i), i=x,y.
|
||||||
|
function UTILS.Vec2Substract(a, b)
|
||||||
|
return {x=a.x-b.x, y=a.y-b.y}
|
||||||
|
end
|
||||||
|
|
||||||
--- Calculate the total vector of two 3D vectors by adding the x,y,z components of each other.
|
--- Calculate the total vector of two 3D vectors by adding the x,y,z components of each other.
|
||||||
-- @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.
|
||||||
@ -1108,6 +1113,14 @@ function UTILS.VecAdd( a, b )
|
|||||||
return {x=a.x+b.x, y=a.y+b.y, z=a.z+b.z}
|
return {x=a.x+b.x, y=a.y+b.y, z=a.z+b.z}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Calculate the total vector of two 2D vectors by adding the x,y components of each other.
|
||||||
|
-- @param DCS#Vec2 a Vector in 2D with x, y components.
|
||||||
|
-- @param DCS#Vec2 b Vector in 2D with x, y components.
|
||||||
|
-- @return DCS#Vec2 Vector c=a+b with c(i)=a(i)+b(i), i=x,y.
|
||||||
|
function UTILS.Vec2Add(a, b)
|
||||||
|
return {x=a.x+b.x, y=a.y+b.y}
|
||||||
|
end
|
||||||
|
|
||||||
--- Calculate the angle between two 3D vectors.
|
--- Calculate the angle 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.
|
||||||
@ -1169,6 +1182,7 @@ 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.
|
||||||
@ -1240,6 +1254,7 @@ 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".
|
||||||
@ -1276,6 +1291,7 @@ 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()
|
||||||
@ -1321,26 +1337,6 @@ function UTILS.GetMissionDayOfYear( Time )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the current date.
|
|
||||||
-- @return #string Mission date in yyyy/mm/dd format.
|
|
||||||
-- @return #number The year anno domini.
|
|
||||||
-- @return #number The month.
|
|
||||||
-- @return #number The day.
|
|
||||||
function UTILS.GetDate()
|
|
||||||
|
|
||||||
-- Mission start date
|
|
||||||
local date, year, month, day = UTILS.GetDCSMissionDate()
|
|
||||||
|
|
||||||
local time = timer.getAbsTime()
|
|
||||||
|
|
||||||
local clock = UTILS.SecondsToClock( time, false )
|
|
||||||
|
|
||||||
local x = tonumber( UTILS.Split( clock, "+" )[2] )
|
|
||||||
|
|
||||||
local day = day + x
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the magnetic declination of the map.
|
--- Returns the magnetic declination of the map.
|
||||||
-- Returned values for the current maps are:
|
-- Returned values for the current maps are:
|
||||||
--
|
--
|
||||||
@ -1410,7 +1406,8 @@ function UTILS.CheckMemory( output )
|
|||||||
return mem
|
return mem
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the coalition name from its numerical ID, e.g. coalition.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").
|
||||||
function UTILS.GetCoalitionName(Coalition)
|
function UTILS.GetCoalitionName(Coalition)
|
||||||
@ -1509,6 +1506,7 @@ 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.
|
||||||
@ -1542,31 +1540,18 @@ 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 )
|
local frac = function(n) return n - floor(n) end
|
||||||
return n - floor( n )
|
local cos = function(d) return math.cos(rad(d)) end
|
||||||
end
|
local acos = function(d) return deg(math.acos(d)) end
|
||||||
local cos = function( d )
|
local sin = function(d) return math.sin(rad(d)) end
|
||||||
return math.cos( rad( d ) )
|
local asin = function(d) return deg(math.asin(d)) end
|
||||||
end
|
local tan = function(d) return math.tan(rad(d)) end
|
||||||
local acos = function( d )
|
local atan = function(d) return deg(math.atan(d)) end
|
||||||
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
|
||||||
@ -1770,6 +1755,7 @@ function UTILS.IsLoadingDoorOpen( unit_name )
|
|||||||
if ret_val == false then
|
if ret_val == false then
|
||||||
BASE:T(unit_name .. " all doors are closed")
|
BASE:T(unit_name .. " all doors are closed")
|
||||||
end
|
end
|
||||||
|
|
||||||
return ret_val
|
return ret_val
|
||||||
|
|
||||||
end -- nil
|
end -- nil
|
||||||
@ -1910,7 +1896,9 @@ 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 ) 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)
|
table.insert(jtacGeneratedLaserCodes, _code)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -2177,9 +2165,7 @@ 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
|
if Reduce == false then reduce = false end
|
||||||
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
|
||||||
@ -2198,9 +2184,8 @@ function UTILS.LoadStationaryListOfGroups( Path, Filename, Reduce )
|
|||||||
local data = { groupname=groupname, size=size, coordinate=coordinate, group=GROUP:FindByName(groupname) }
|
local data = { groupname=groupname, size=size, coordinate=coordinate, group=GROUP:FindByName(groupname) }
|
||||||
if reduce then
|
if reduce then
|
||||||
local actualgroup = GROUP:FindByName(groupname)
|
local actualgroup = GROUP:FindByName(groupname)
|
||||||
local actualsize = actualgroup:CountAliveUnits()
|
if actualgroup and actualgroup:IsAlive() and actualgroup:CountAliveUnits() > size then
|
||||||
if actualsize > size then
|
local reduction = actualgroup:CountAliveUnits() - size
|
||||||
local reduction = actualsize - size
|
|
||||||
BASE:I("Reducing groupsize by ".. reduction .. " units!")
|
BASE:I("Reducing groupsize by ".. reduction .. " units!")
|
||||||
-- reduce existing group
|
-- reduce existing group
|
||||||
local units = actualgroup:GetUnits()
|
local units = actualgroup:GetUnits()
|
||||||
@ -2226,9 +2211,7 @@ 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
|
if Spawn == false then spawn = false end
|
||||||
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()
|
||||||
@ -2251,7 +2234,10 @@ 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 ):InitDelayOff():OnSpawnGroup( function( spwndgrp )
|
local group = SPAWN:New(groupname)
|
||||||
|
: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
|
||||||
@ -2263,7 +2249,9 @@ function UTILS.LoadSetOfGroups( Path, Filename, Spawn )
|
|||||||
units2[i]:Destroy(false)
|
units2[i]:Destroy(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end ):SpawnFromCoordinate( coordinate )
|
end
|
||||||
|
)
|
||||||
|
:SpawnFromCoordinate(coordinate)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -2311,9 +2299,7 @@ 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
|
if Reduce == false then reduce = false end
|
||||||
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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user