From f1c03e1b86b1300377cce3da05717afd1dec5d2a Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 12 May 2024 22:30:17 +0200 Subject: [PATCH 01/19] sound --- Moose Development/Moose/Sound/RadioQueue.lua | 7 +- Moose Development/Moose/Sound/SoundOutput.lua | 2 +- Moose Development/Moose/Utilities/Utils.lua | 115 ++++++++++++++---- 3 files changed, 96 insertions(+), 28 deletions(-) diff --git a/Moose Development/Moose/Sound/RadioQueue.lua b/Moose Development/Moose/Sound/RadioQueue.lua index 7f320cedc..a851abc0c 100644 --- a/Moose Development/Moose/Sound/RadioQueue.lua +++ b/Moose Development/Moose/Sound/RadioQueue.lua @@ -361,6 +361,7 @@ end -- @param #RADIOQUEUE self -- @param #RADIOQUEUE.Transmission transmission The transmission. function RADIOQUEUE:Broadcast(transmission) + self:T("Broarcast") if ((transmission.soundfile and transmission.soundfile.useSRS) or transmission.soundtext) and self.msrs then self:_BroadcastSRS(transmission) @@ -425,7 +426,7 @@ function RADIOQUEUE:Broadcast(transmission) else -- Broadcasting from carrier. No subtitle possible. Need to send messages to players. - self:T(self.lid..string.format("Broadcasting via trigger.action.radioTransmission().")) + self:T(self.lid..string.format("Broadcasting via trigger.action.radioTransmission()")) -- Position from where to transmit. local vec3=nil @@ -453,6 +454,8 @@ function RADIOQUEUE:Broadcast(transmission) local text=string.format("file=%s, freq=%.2f MHz, duration=%.2f sec, subtitle=%s", filename, self.frequency/1000000, transmission.duration, transmission.subtitle or "") MESSAGE:New(string.format(text, filename, transmission.duration, transmission.subtitle or ""), 5, "RADIOQUEUE "..self.alias):ToAll() end + else + self:E("ERROR: Could not get vec3 to determin transmission origin! Did you specify a sender and is it still alive?") end end @@ -482,7 +485,7 @@ end --- Check radio queue for transmissions to be broadcasted. -- @param #RADIOQUEUE self function RADIOQUEUE:_CheckRadioQueue() - --env.info("FF check radio queue "..self.alias) + env.info("FF check radio queue "..self.alias) -- Check if queue is empty. if #self.queue==0 then diff --git a/Moose Development/Moose/Sound/SoundOutput.lua b/Moose Development/Moose/Sound/SoundOutput.lua index 408be7b96..e3ef086a8 100644 --- a/Moose Development/Moose/Sound/SoundOutput.lua +++ b/Moose Development/Moose/Sound/SoundOutput.lua @@ -160,7 +160,7 @@ do -- Sound File -- @param #string FileName The name of the sound file, e.g. "Hello World.ogg". -- @param #string Path The path of the directory, where the sound file is located. Default is "l10n/DEFAULT/" within the miz file. -- @param #number Duration Duration in seconds, how long it takes to play the sound file. Default is 3 seconds. - -- @param #bolean UseSrs Set if SRS should be used to play this file. Default is false. + -- @param #boolean UseSrs Set if SRS should be used to play this file. Default is false. -- @return #SOUNDFILE self function SOUNDFILE:New(FileName, Path, Duration, UseSrs) diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index 5d53100e9..5234ca6db 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -3138,7 +3138,7 @@ end -- @param #table Table The table. -- @param #table Object The object to check. -- @param #string Key (Optional) Key to check. By default, the object itself is checked. --- @return #booolen Returns `true` if object is in table. +-- @return #boolean Returns `true` if object is in table. function UTILS.IsInTable(Table, Object, Key) for key, object in pairs(Table) do @@ -3160,7 +3160,7 @@ end -- @param #table Table The table. -- @param #table Objects The objects to check. -- @param #string Key (Optional) Key to check. --- @return #booolen Returns `true` if object is in table. +-- @return #boolean Returns `true` if object is in table. function UTILS.IsAnyInTable(Table, Objects, Key) for _,Object in pairs(UTILS.EnsureTable(Objects)) do @@ -3308,14 +3308,14 @@ end --- Checks if the current time is in between start_time and end_time -- @param #string time_string_01 Time string like "07:15:22" -- @param #string time_string_02 Time string like "08:11:27" --- @return #bool True if it is, False if it's not +-- @return #boolean True if it is, False if it's not function UTILS.TimeBetween(start_time, end_time) return UTILS.TimeLaterThan(start_time) and UTILS.TimeBefore(end_time) end --- Easy to read one line to roll the dice on something. 1% is very unlikely to happen, 99% is very likely to happen -- @param #number chance (optional) Percentage chance you want something to happen. Defaults to a random number if not given --- @return #bool True if the dice roll was within the given percentage chance of happening +-- @return #boolean True if the dice roll was within the given percentage chance of happening function UTILS.PercentageChance(chance) chance = chance or math.random(0, 100) chance = UTILS.Clamp(chance, 0, 100) @@ -3368,10 +3368,10 @@ function UTILS.RemapValue(value, old_min, old_max, new_min, new_max) end --- Given a triangle made out of 3 vector 2s, return a vec2 that is a random number in this triangle --- @param #Vec2 pt1 Min value to remap from --- @param #Vec2 pt2 Max value to remap from --- @param #Vec2 pt3 Max value to remap from --- @return #Vec2 Random point in triangle +-- @param DCS#Vec2 pt1 Min value to remap from +-- @param DCS#Vec2 pt2 Max value to remap from +-- @param DCS#Vec2 pt3 Max value to remap from +-- @return DCS#Vec2 Random point in triangle function UTILS.RandomPointInTriangle(pt1, pt2, pt3) local pt = {math.random(), math.random()} table.sort(pt) @@ -3389,7 +3389,7 @@ end -- @param #number angle Min value to remap from -- @param #number min Max value to remap from -- @param #number max Max value to remap from --- @return #bool +-- @return #boolean function UTILS.AngleBetween(angle, min, max) angle = (360 + (angle % 360)) % 360 min = (360 + min % 360) % 360 @@ -3449,10 +3449,10 @@ end --- Rotates a point around another point with a given angle. Useful if you're loading in groups or --- statics but you want to rotate them all as a collection. You can get the center point of everything --- and then rotate all the positions of every object around this center point. --- @param #Vec2 point Point that you want to rotate --- @param #Vec2 pivot Pivot point of the rotation +-- @param DCS#Vec2 point Point that you want to rotate +-- @param DCS#Vec2 pivot Pivot point of the rotation -- @param #number angle How many degrees the point should be rotated --- @return #Vec Rotated point +-- @return DCS#Vec2 Rotated point function UTILS.RotatePointAroundPivot(point, pivot, angle) local radians = math.rad(angle) @@ -3484,7 +3484,7 @@ end --- Check if a string starts with something -- @param #string str String to check -- @param #string value --- @return #bool True if str starts with value +-- @return #boolean True if str starts with value function string.startswith(str, value) return string.sub(str,1,string.len(value)) == value end @@ -3493,7 +3493,7 @@ end --- Check if a string ends with something -- @param #string str String to check -- @param #string value --- @return #bool True if str ends with value +-- @return #boolean True if str ends with value function string.endswith(str, value) return value == "" or str:sub(-#value) == value end @@ -3516,16 +3516,16 @@ end --- string.split("hello_dcs_world", "-") would return {"hello", "dcs", "world"} -- @param #string str -- @param #string value --- @return #bool True if str contains value +-- @return #boolean True if str contains value function string.contains(str, value) return string.match(str, value) end --- Moves an object from one table to another --- @param #obj object to move --- @param #from_table table to move from --- @param #to_table table to move to +-- @param #table obj object to move +-- @param #table from_table table to move from +-- @param #table to_table table to move to function table.move_object(obj, from_table, to_table) local index for i, v in pairs(from_table) do @@ -3544,7 +3544,7 @@ end --- The table can be made up out of complex tables or values as well -- @param #table tbl -- @param #string element --- @return #bool True if tbl contains element +-- @return #boolean True if tbl contains element function table.contains(tbl, element) if element == nil or tbl == nil then return false end @@ -3561,7 +3561,7 @@ end --- Checks if a table contains a specific key. -- @param #table tbl Table to check -- @param #string key Key to look for --- @return #bool True if tbl contains key +-- @return #boolean True if tbl contains key function table.contains_key(tbl, key) if tbl[key] ~= nil then return true else return false end end @@ -3608,7 +3608,7 @@ end --- Finds the index of an element in a table. -- @param #table table Table to search -- @param #string element Element to find --- @return #int Index of the element, or nil if not found +-- @return #number Index of the element, or nil if not found function table.index_of(table, element) for i, v in ipairs(table) do if v == element then @@ -3620,7 +3620,7 @@ end --- Counts the number of elements in a table. -- @param #table T Table to count --- @return #int Number of elements in the table +-- @return #number Number of elements in the table function table.length(T) local count = 0 for _ in pairs(T) do count = count + 1 end @@ -3629,8 +3629,8 @@ end --- Slices a table between two indices, much like Python's my_list[2:-1] -- @param #table tbl Table to slice --- @param #int first Starting index --- @param #int last Ending index +-- @param #number first Starting index +-- @param #number last Ending index -- @return #table Sliced table function table.slice(tbl, first, last) local sliced = {} @@ -3651,7 +3651,7 @@ end --- Counts the number of occurrences of a value in a table. -- @param #table tbl Table to search -- @param #string value Value to count --- @return #int Number of occurrences of the value +-- @return #number Number of occurrences of the value function table.count_value(tbl, value) local count = 0 for _, item in pairs(tbl) do @@ -3932,3 +3932,68 @@ function UTILS.MGRSStringToSRSFriendly(Text,Slow) Text = "MGRS;"..Text return Text end + + +--- Read csv file and convert it to a lua table. +-- The csv must have a header specifing the names of the columns. The column names are used as table keys. +-- @param #string filename File name including full path on local disk. +-- @return #table The table filled with data from the csv file. +function UTILS.ReadCSV(filename) + + if not UTILS.FileExists(filename) then + + env.error("File does not exist") + return nil + + end + + --- Function that load data from a file. + local function _loadfile( filename ) + local f = io.open( filename, "rb" ) + if f then + -- self:I(self.lid..string.format("Loading player results from file %s", tostring(filename))) + local data = f:read( "*all" ) + f:close() + return data + else + BASE:E( self.lid .. string.format( "WARNING: Could not load player results from file %s. File might not exist just yet.", tostring( filename ) ) ) + return nil + end + end + + -- Load asset data from file. + local data = _loadfile( filename ) + + local lines=UTILS.Split(data, "\n" ) + + local sep=";" + + local columns=UTILS.Split(lines[1], sep) + + BASE:I(columns) + + -- Remove header line. + table.remove(lines, 1) + + local csvdata={} + for i, line in pairs(lines) do + + local row={} + for j, value in pairs(UTILS.Split(line, sep)) do + + local key=columns[j] + + + --env.info(string.format("i=%d, j=%d key=%s value=%s", i,j, key, value)) + + row[key]=value + + end + table.insert(csvdata, row) + BASE:E(row) + + + end + + return csvdata +end From 7bac0f32fc6a57e7b9066fa773b77b4802a1dd5d Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 25 May 2024 01:56:23 +0200 Subject: [PATCH 02/19] Update - Sound input --- Moose Development/Moose/Ops/ATIS.lua | 51 ++++++++++++++++++- Moose Development/Moose/Sound/SoundOutput.lua | 3 ++ Moose Development/Moose/Utilities/Utils.lua | 8 ++- 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index a98245b0b..50470fea1 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -495,7 +495,7 @@ ATIS.Alphabet = { -- @field #number TheChannel -10° (West). -- @field #number Syria +5° (East). -- @field #number MarianaIslands +2° (East). --- @field #number SinaiMao +5° (East). +-- @field #number SinaiMap +5° (East). ATIS.RunwayM2T = { Caucasus = 0, Nevada = 12, @@ -1088,6 +1088,55 @@ function ATIS:SetSoundfilesPath( path ) return self end +--- Set the path to the csv file that contains information about the used sound files. +-- @param #ATIS self +-- @param #string csvfile Full path to the csv file on your local disk (not in the miz file). +-- @return #ATIS self +function ATIS:SetSoundfilesInfoFile( csvfile ) + + --- Local function to return the ATIS.Soundfile for a given file name + local function getSound(filename) + for key,_soundfile in pairs(ATIS.Sound) do + local soundfile=_soundfile --#ATIS.Soundfile + if filename==soundfile.filename then + return soundfile + end + end + return nil + end + + local data=UTILS.ReadCSV(csvfile) + + if data then + + + env.info("FF sound info") + + local soundfiles={} + + for i,soundinfo in pairs(data) do + local sound=soundinfo --#Soundinfo + + local soundfile=getSound(sound.filename..".ogg") --#ATIS.Soundfile + + if soundfile then + + -- Set duration + soundfile.duration=soundinfo.duration + + else + self:E(string.format("ERROR: Could not get info for sound file %s", sound.filename)) + end + + end + else + self:E("ERROR: Could not read sound csv file!") + end + + + return self +end + --- Set airborne unit (airplane or helicopter), used to transmit radio messages including subtitles. -- Best is to place the unit on a parking spot of the airbase and set it to *uncontrolled* in the mission editor. -- @param #ATIS self diff --git a/Moose Development/Moose/Sound/SoundOutput.lua b/Moose Development/Moose/Sound/SoundOutput.lua index e3ef086a8..c92b4d1f9 100644 --- a/Moose Development/Moose/Sound/SoundOutput.lua +++ b/Moose Development/Moose/Sound/SoundOutput.lua @@ -249,6 +249,9 @@ do -- Sound File -- @param #string Duration Duration in seconds. Default 3 seconds. -- @return #SOUNDFILE self function SOUNDFILE:SetDuration(Duration) + if Duration and type(Duration)=="string" then + Duration=tonumber(Duration) + end self.duration=Duration or 3 return self end diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index 5234ca6db..6f2987121 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -3966,6 +3966,11 @@ function UTILS.ReadCSV(filename) local lines=UTILS.Split(data, "\n" ) + -- Remove carriage returns from end of lines + for _,line in pairs(lines) do + line=string.gsub(line, "[\n\r]","") + end + local sep=";" local columns=UTILS.Split(lines[1], sep) @@ -3977,11 +3982,12 @@ function UTILS.ReadCSV(filename) local csvdata={} for i, line in pairs(lines) do + line=string.gsub(line, "[\n\r]","") local row={} for j, value in pairs(UTILS.Split(line, sep)) do - local key=columns[j] + local key=string.gsub(columns[j], "[\n\r]","") --env.info(string.format("i=%d, j=%d key=%s value=%s", i,j, key, value)) From a6568a955ff274a6ab38ad17d6497238f3dc1bdc Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 26 May 2024 23:13:03 +0200 Subject: [PATCH 03/19] Update - sound --- Moose Development/Moose/Ops/ATIS.lua | 4 +++- Moose Development/Moose/Sound/RadioQueue.lua | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index 50470fea1..a27bcc953 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -1122,7 +1122,9 @@ function ATIS:SetSoundfilesInfoFile( csvfile ) if soundfile then -- Set duration - soundfile.duration=soundinfo.duration + soundfile.duration=tonumber(soundinfo.duration) + + self:I(soundfile) else self:E(string.format("ERROR: Could not get info for sound file %s", sound.filename)) diff --git a/Moose Development/Moose/Sound/RadioQueue.lua b/Moose Development/Moose/Sound/RadioQueue.lua index a851abc0c..a065de743 100644 --- a/Moose Development/Moose/Sound/RadioQueue.lua +++ b/Moose Development/Moose/Sound/RadioQueue.lua @@ -268,7 +268,7 @@ function RADIOQUEUE:NewTransmission(filename, duration, path, tstart, interval, return nil end if type(duration)~="number" then - self:E(self.lid.."ERROR: Duration specified is NOT a number.") + self:E(self.lid..string.format("ERROR: Duration specified is NOT a number but type=%s. Filename=%s, duration=%s", type(duration), tostring(filename), tostring(duration))) return nil end From 08745c910c308332f5e611bb73b68daba1d76e3c Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 8 Jun 2024 22:34:09 +0200 Subject: [PATCH 04/19] ATIS - custom sounds --- Moose Development/Moose/Functional/Range.lua | 2 +- Moose Development/Moose/Ops/ATIS.lua | 28 ++++++++------------ Moose Development/Moose/Sound/RadioQueue.lua | 1 - 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index 3019fe29c..1d69bdf4e 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -7,7 +7,7 @@ -- Implementation is based on the [Simple Range Script](https://forums.eagle.ru/showthread.php?t=157991) by Ciribob, which itself was motivated -- by a script by SNAFU [see here](https://forums.eagle.ru/showthread.php?t=109174). -- --- [476th - Air Weapons Range Objects mod](http://www.476vfightergroup.com/downloads.php?do=file&id=287) is highly recommended for this class. +-- [476th - Air Weapons Range Objects mod](https://www.476vfightergroup.com/downloads.php?do=download&downloadid=482) is highly recommended for this class. -- -- **Main Features:** -- diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index a27bcc953..10ce897b6 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -897,6 +897,7 @@ ATIS.version = "1.0.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO: Correct fog for elevation. +-- TODO: Generalize sound files input to be able to use custom made sounds. -- DONE: Option to add multiple frequencies for SRS -- DONE: Zulu time --> Zulu in output. -- DONE: Fix for AB not having a runway - Helopost like Naqoura @@ -1089,8 +1090,9 @@ function ATIS:SetSoundfilesPath( path ) end --- Set the path to the csv file that contains information about the used sound files. +-- The parameter file has to be located on your local disk (**not** inside the miz file). -- @param #ATIS self --- @param #string csvfile Full path to the csv file on your local disk (not in the miz file). +-- @param #string csvfile Full path to the csv file on your local disk. -- @return #ATIS self function ATIS:SetSoundfilesInfoFile( csvfile ) @@ -1100,31 +1102,25 @@ function ATIS:SetSoundfilesInfoFile( csvfile ) local soundfile=_soundfile --#ATIS.Soundfile if filename==soundfile.filename then return soundfile - end + end end return nil end + -- Read csv file local data=UTILS.ReadCSV(csvfile) if data then - - - env.info("FF sound info") - - local soundfiles={} - - for i,soundinfo in pairs(data) do - local sound=soundinfo --#Soundinfo + + for i,sound in pairs(data) do + -- Get the ATIS.Soundfile local soundfile=getSound(sound.filename..".ogg") --#ATIS.Soundfile if soundfile then -- Set duration - soundfile.duration=tonumber(soundinfo.duration) - - self:I(soundfile) + soundfile.duration=tonumber(sound.duration) else self:E(string.format("ERROR: Could not get info for sound file %s", sound.filename)) @@ -1132,7 +1128,7 @@ function ATIS:SetSoundfilesInfoFile( csvfile ) end else - self:E("ERROR: Could not read sound csv file!") + self:E(string.format("ERROR: Could not read sound csv file!")) end @@ -2619,13 +2615,10 @@ function ATIS:onafterBroadcast( From, Event, To ) local subtitle = "" if runwayLanding then local actrun = self.gettext:GetEntry("ACTIVELANDING",self.locale) - --subtitle=string.format("Active runway landing %s", runwayLanding) subtitle=string.format("%s %s", actrun, runwayLanding) if rwyLandingLeft==true then - --subtitle=subtitle.." Left" subtitle=subtitle.." "..self.gettext:GetEntry("LEFT",self.locale) elseif rwyLandingLeft==false then - --subtitle=subtitle.." Right" subtitle=subtitle.." "..self.gettext:GetEntry("RIGHT",self.locale) end alltext = alltext .. ";\n" .. subtitle @@ -2698,6 +2691,7 @@ function ATIS:onafterBroadcast( From, Event, To ) alltext = alltext .. ";\n" .. subtitle end end + -- Airfield elevation if self.elevation then diff --git a/Moose Development/Moose/Sound/RadioQueue.lua b/Moose Development/Moose/Sound/RadioQueue.lua index a065de743..43a5c6aac 100644 --- a/Moose Development/Moose/Sound/RadioQueue.lua +++ b/Moose Development/Moose/Sound/RadioQueue.lua @@ -485,7 +485,6 @@ end --- Check radio queue for transmissions to be broadcasted. -- @param #RADIOQUEUE self function RADIOQUEUE:_CheckRadioQueue() - env.info("FF check radio queue "..self.alias) -- Check if queue is empty. if #self.queue==0 then From b60435fb2c7ceded66cd0622d37e44dc22449788 Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 9 Jun 2024 22:47:43 +0200 Subject: [PATCH 05/19] Update ATIS.lua - ATIS.Sound --> self.Sound --- Moose Development/Moose/Ops/ATIS.lua | 227 +++++++++++++++------------ 1 file changed, 123 insertions(+), 104 deletions(-) diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index 10ce897b6..e6469713b 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -618,6 +618,8 @@ ATIS.ICAOPhraseology = { -- @field #ATIS.Soundfile VORFrequency ATIS.Sound = { ActiveRunway = { filename = "ActiveRunway.ogg", duration = 0.99 }, + ActiveRunwayDeparture = { filename = "ActiveRunwayDeparture.ogg", duration = 0.99 }, + ActiveRunwayArrival = { filename = "ActiveRunwayArrival.ogg", duration = 0.99 }, AdviceOnInitial = { filename = "AdviceOnInitial.ogg", duration = 3.00 }, Airport = { filename = "Airport.ogg", duration = 0.66 }, Altimeter = { filename = "Altimeter.ogg", duration = 0.68 }, @@ -1098,7 +1100,7 @@ function ATIS:SetSoundfilesInfoFile( csvfile ) --- Local function to return the ATIS.Soundfile for a given file name local function getSound(filename) - for key,_soundfile in pairs(ATIS.Sound) do + for key,_soundfile in pairs(self.Sound) do local soundfile=_soundfile --#ATIS.Soundfile if filename==soundfile.filename then return soundfile @@ -1700,16 +1702,16 @@ function ATIS:onafterStart( From, Event, To ) self.radioqueue:SetRadioPower( self.power ) -- Init numbers. - self.radioqueue:SetDigit( 0, ATIS.Sound.N0.filename, ATIS.Sound.N0.duration, self.soundpath ) - self.radioqueue:SetDigit( 1, ATIS.Sound.N1.filename, ATIS.Sound.N1.duration, self.soundpath ) - self.radioqueue:SetDigit( 2, ATIS.Sound.N2.filename, ATIS.Sound.N2.duration, self.soundpath ) - self.radioqueue:SetDigit( 3, ATIS.Sound.N3.filename, ATIS.Sound.N3.duration, self.soundpath ) - self.radioqueue:SetDigit( 4, ATIS.Sound.N4.filename, ATIS.Sound.N4.duration, self.soundpath ) - self.radioqueue:SetDigit( 5, ATIS.Sound.N5.filename, ATIS.Sound.N5.duration, self.soundpath ) - self.radioqueue:SetDigit( 6, ATIS.Sound.N6.filename, ATIS.Sound.N6.duration, self.soundpath ) - self.radioqueue:SetDigit( 7, ATIS.Sound.N7.filename, ATIS.Sound.N7.duration, self.soundpath ) - self.radioqueue:SetDigit( 8, ATIS.Sound.N8.filename, ATIS.Sound.N8.duration, self.soundpath ) - self.radioqueue:SetDigit( 9, ATIS.Sound.N9.filename, ATIS.Sound.N9.duration, self.soundpath ) + self.radioqueue:SetDigit( 0, self.Sound.N0.filename, self.Sound.N0.duration, self.soundpath ) + self.radioqueue:SetDigit( 1, self.Sound.N1.filename, self.Sound.N1.duration, self.soundpath ) + self.radioqueue:SetDigit( 2, self.Sound.N2.filename, self.Sound.N2.duration, self.soundpath ) + self.radioqueue:SetDigit( 3, self.Sound.N3.filename, self.Sound.N3.duration, self.soundpath ) + self.radioqueue:SetDigit( 4, self.Sound.N4.filename, self.Sound.N4.duration, self.soundpath ) + self.radioqueue:SetDigit( 5, self.Sound.N5.filename, self.Sound.N5.duration, self.soundpath ) + self.radioqueue:SetDigit( 6, self.Sound.N6.filename, self.Sound.N6.duration, self.soundpath ) + self.radioqueue:SetDigit( 7, self.Sound.N7.filename, self.Sound.N7.duration, self.soundpath ) + self.radioqueue:SetDigit( 8, self.Sound.N8.filename, self.Sound.N8.duration, self.soundpath ) + self.radioqueue:SetDigit( 9, self.Sound.N9.filename, self.Sound.N9.duration, self.soundpath ) -- Start radio queue. self.radioqueue:Start( 1, 0.1 ) @@ -2194,36 +2196,36 @@ function ATIS:onafterBroadcast( From, Event, To ) -- No cloud info for dynamic weather. local CloudCover = {} -- #ATIS.Soundfile - CloudCover = ATIS.Sound.CloudsNotAvailable + CloudCover = self.Sound.CloudsNotAvailable --local CLOUDSsub = "Cloud coverage information not available" local CLOUDSsub = self.gettext:GetEntry("NOCLOUDINFO",self.locale) -- Only valid for static weather. if static then if clouddens >= 9 then -- Overcast 9,10 - CloudCover = ATIS.Sound.CloudsOvercast + CloudCover = self.Sound.CloudsOvercast --CLOUDSsub = "Overcast" CLOUDSsub = self.gettext:GetEntry("OVERCAST",self.locale) elseif clouddens >= 7 then -- Broken 7,8 - CloudCover = ATIS.Sound.CloudsBroken + CloudCover = self.Sound.CloudsBroken --CLOUDSsub = "Broken clouds" CLOUDSsub = self.gettext:GetEntry("BROKEN",self.locale) elseif clouddens >= 4 then -- Scattered 4,5,6 - CloudCover = ATIS.Sound.CloudsScattered + CloudCover = self.Sound.CloudsScattered --CLOUDSsub = "Scattered clouds" CLOUDSsub = self.gettext:GetEntry("SCATTERED",self.locale) elseif clouddens >= 1 then -- Few 1,2,3 - CloudCover = ATIS.Sound.CloudsFew + CloudCover = self.Sound.CloudsFew --CLOUDSsub = "Few clouds" CLOUDSsub = self.gettext:GetEntry("FEWCLOUDS",self.locale) else -- No clouds CLOUDBASE = nil CLOUDCEIL = nil - CloudCover = ATIS.Sound.CloudsNo + CloudCover = self.Sound.CloudsNo --CLOUDSsub = "No clouds" CLOUDSsub = self.gettext:GetEntry("NOCLOUDS",self.locale) end @@ -2257,7 +2259,7 @@ function ATIS:onafterBroadcast( From, Event, To ) subtitle = string.format( "%s %s", information, NATO ) local _INFORMATION = subtitle if not self.useSRS then - self:Transmission( ATIS.Sound.Information, 0.5, subtitle ) + self:Transmission( self.Sound.Information, 0.5, subtitle ) self.radioqueue:NewTransmission( string.format( "NATO Alphabet/%s.ogg", NATO ), 0.75, self.soundpath ) end alltext = alltext .. ";\n" .. subtitle @@ -2266,7 +2268,7 @@ function ATIS:onafterBroadcast( From, Event, To ) subtitle = string.format( "%s Zulu", ZULU ) if not self.useSRS then self.radioqueue:Number2Transmission( ZULU, nil, 0.5 ) - self:Transmission( ATIS.Sound.Zulu, 0.2, subtitle ) + self:Transmission( self.Sound.Zulu, 0.2, subtitle ) end alltext = alltext .. ";\n" .. subtitle @@ -2277,9 +2279,9 @@ function ATIS:onafterBroadcast( From, Event, To ) --subtitle = string.format( "Sunrise at %s local time", SUNRISE ) subtitle = string.format( sunrise, SUNRISE ) if not self.useSRS then - self:Transmission( ATIS.Sound.SunriseAt, 0.5, subtitle ) + self:Transmission( self.Sound.SunriseAt, 0.5, subtitle ) self.radioqueue:Number2Transmission( SUNRISE, nil, 0.2 ) - self:Transmission( ATIS.Sound.TimeLocal, 0.2 ) + self:Transmission( self.Sound.TimeLocal, 0.2 ) end alltext = alltext .. ";\n" .. subtitle @@ -2288,9 +2290,9 @@ function ATIS:onafterBroadcast( From, Event, To ) --subtitle = string.format( "Sunset at %s local time", SUNSET ) subtitle = string.format( sunset, SUNSET ) if not self.useSRS then - self:Transmission( ATIS.Sound.SunsetAt, 0.5, subtitle ) + self:Transmission( self.Sound.SunsetAt, 0.5, subtitle ) self.radioqueue:Number2Transmission( SUNSET, nil, 0.5 ) - self:Transmission( ATIS.Sound.TimeLocal, 0.2 ) + self:Transmission( self.Sound.TimeLocal, 0.2 ) end alltext = alltext .. ";\n" .. subtitle end @@ -2315,17 +2317,17 @@ function ATIS:onafterBroadcast( From, Event, To ) end local _WIND = subtitle if not self.useSRS then - self:Transmission( ATIS.Sound.WindFrom, 1.0, subtitle ) + self:Transmission( self.Sound.WindFrom, 1.0, subtitle ) self.radioqueue:Number2Transmission( WINDFROM ) - self:Transmission( ATIS.Sound.At, 0.2 ) + self:Transmission( self.Sound.At, 0.2 ) self.radioqueue:Number2Transmission( WINDSPEED ) if self.metric then - self:Transmission( ATIS.Sound.MetersPerSecond, 0.2 ) + self:Transmission( self.Sound.MetersPerSecond, 0.2 ) else - self:Transmission( ATIS.Sound.Knots, 0.2 ) + self:Transmission( self.Sound.Knots, 0.2 ) end if turbulence > 0 then - self:Transmission( ATIS.Sound.Gusting, 0.2 ) + self:Transmission( self.Sound.Gusting, 0.2 ) end end alltext = alltext .. ";\n" .. subtitle @@ -2341,12 +2343,12 @@ function ATIS:onafterBroadcast( From, Event, To ) subtitle = string.format( visi, VISIBILITY ) end if not self.useSRS then - self:Transmission( ATIS.Sound.Visibilty, 1.0, subtitle ) + self:Transmission( self.Sound.Visibilty, 1.0, subtitle ) self.radioqueue:Number2Transmission( VISIBILITY ) if self.metric then - self:Transmission( ATIS.Sound.Kilometers, 0.2 ) + self:Transmission( self.Sound.Kilometers, 0.2 ) else - self:Transmission( ATIS.Sound.StatuteMiles, 0.2 ) + self:Transmission( self.Sound.StatuteMiles, 0.2 ) end end alltext = alltext .. ";\n" .. subtitle @@ -2397,21 +2399,21 @@ function ATIS:onafterBroadcast( From, Event, To ) --subtitle = string.format( "Weather phenomena: %s", wpsub ) subtitle = string.format( "%s: %s", phenos, wpsub ) if not self.useSRS then - self:Transmission( ATIS.Sound.WeatherPhenomena, 1.0, subtitle ) + self:Transmission( self.Sound.WeatherPhenomena, 1.0, subtitle ) if precepitation == 1 then - self:Transmission( ATIS.Sound.Rain, 0.5 ) + self:Transmission( self.Sound.Rain, 0.5 ) elseif precepitation == 2 then - self:Transmission( ATIS.Sound.ThunderStorm, 0.5 ) + self:Transmission( self.Sound.ThunderStorm, 0.5 ) elseif precepitation == 3 then - self:Transmission( ATIS.Sound.Snow, 0.5 ) + self:Transmission( self.Sound.Snow, 0.5 ) elseif precepitation == 4 then - self:Transmission( ATIS.Sound.SnowStorm, 0.5 ) + self:Transmission( self.Sound.SnowStorm, 0.5 ) end if fog then - self:Transmission( ATIS.Sound.Fog, 0.5 ) + self:Transmission( self.Sound.Fog, 0.5 ) end if dust then - self:Transmission( ATIS.Sound.Dust, 0.5 ) + self:Transmission( self.Sound.Dust, 0.5 ) end end alltext = alltext .. ";\n" .. subtitle @@ -2437,29 +2439,29 @@ function ATIS:onafterBroadcast( From, Event, To ) subtitle = string.format( cloudbase, cbase, cceil ) end if not self.useSRS then - self:Transmission( ATIS.Sound.CloudBase, 1.0, subtitle ) + self:Transmission( self.Sound.CloudBase, 1.0, subtitle ) if tonumber( CLOUDBASE1000 ) > 0 then self.radioqueue:Number2Transmission( CLOUDBASE1000 ) - self:Transmission( ATIS.Sound.Thousand, 0.1 ) + self:Transmission( self.Sound.Thousand, 0.1 ) end if tonumber( CLOUDBASE0100 ) > 0 then self.radioqueue:Number2Transmission( CLOUDBASE0100 ) - self:Transmission( ATIS.Sound.Hundred, 0.1 ) + self:Transmission( self.Sound.Hundred, 0.1 ) end -- Ceiling - self:Transmission( ATIS.Sound.CloudCeiling, 0.5 ) + self:Transmission( self.Sound.CloudCeiling, 0.5 ) if tonumber( CLOUDCEIL1000 ) > 0 then self.radioqueue:Number2Transmission( CLOUDCEIL1000 ) - self:Transmission( ATIS.Sound.Thousand, 0.1 ) + self:Transmission( self.Sound.Thousand, 0.1 ) end if tonumber( CLOUDCEIL0100 ) > 0 then self.radioqueue:Number2Transmission( CLOUDCEIL0100 ) - self:Transmission( ATIS.Sound.Hundred, 0.1 ) + self:Transmission( self.Sound.Hundred, 0.1 ) end if self.metric then - self:Transmission( ATIS.Sound.Meters, 0.1 ) + self:Transmission( self.Sound.Meters, 0.1 ) else - self:Transmission( ATIS.Sound.Feet, 0.1 ) + self:Transmission( self.Sound.Feet, 0.1 ) end end end @@ -2487,15 +2489,15 @@ function ATIS:onafterBroadcast( From, Event, To ) end local _TEMPERATURE = subtitle if not self.useSRS then - self:Transmission( ATIS.Sound.Temperature, 1.0, subtitle ) + self:Transmission( self.Sound.Temperature, 1.0, subtitle ) if temperature < 0 then - self:Transmission( ATIS.Sound.Minus, 0.2 ) + self:Transmission( self.Sound.Minus, 0.2 ) end self.radioqueue:Number2Transmission( TEMPERATURE ) if self.TDegF then - self:Transmission( ATIS.Sound.DegreesFahrenheit, 0.2 ) + self:Transmission( self.Sound.DegreesFahrenheit, 0.2 ) else - self:Transmission( ATIS.Sound.DegreesCelsius, 0.2 ) + self:Transmission( self.Sound.DegreesCelsius, 0.2 ) end end alltext = alltext .. ";\n" .. subtitle @@ -2521,15 +2523,15 @@ function ATIS:onafterBroadcast( From, Event, To ) end local _DEWPOINT = subtitle if not self.useSRS then - self:Transmission( ATIS.Sound.DewPoint, 1.0, subtitle ) + self:Transmission( self.Sound.DewPoint, 1.0, subtitle ) if dewpoint < 0 then - self:Transmission( ATIS.Sound.Minus, 0.2 ) + self:Transmission( self.Sound.Minus, 0.2 ) end self.radioqueue:Number2Transmission( DEWPOINT ) if self.TDegF then - self:Transmission( ATIS.Sound.DegreesFahrenheit, 0.2 ) + self:Transmission( self.Sound.DegreesFahrenheit, 0.2 ) else - self:Transmission( ATIS.Sound.DegreesCelsius, 0.2 ) + self:Transmission( self.Sound.DegreesCelsius, 0.2 ) end end alltext = alltext .. ";\n" .. subtitle @@ -2576,33 +2578,33 @@ function ATIS:onafterBroadcast( From, Event, To ) local _ALTIMETER = subtitle if not self.useSRS then - self:Transmission( ATIS.Sound.Altimeter, 1.0, subtitle ) + self:Transmission( self.Sound.Altimeter, 1.0, subtitle ) if not self.qnhonly then - self:Transmission( ATIS.Sound.QNH, 0.5 ) + self:Transmission( self.Sound.QNH, 0.5 ) end self.radioqueue:Number2Transmission( QNH[1] ) if ATIS.ICAOPhraseology[UTILS.GetDCSMap()] then - self:Transmission( ATIS.Sound.Decimal, 0.2 ) + self:Transmission( self.Sound.Decimal, 0.2 ) end self.radioqueue:Number2Transmission( QNH[2] ) if not self.qnhonly then - self:Transmission( ATIS.Sound.QFE, 0.75 ) + self:Transmission( self.Sound.QFE, 0.75 ) self.radioqueue:Number2Transmission( QFE[1] ) if ATIS.ICAOPhraseology[UTILS.GetDCSMap()] then - self:Transmission( ATIS.Sound.Decimal, 0.2 ) + self:Transmission( self.Sound.Decimal, 0.2 ) end self.radioqueue:Number2Transmission( QFE[2] ) end if self.PmmHg then - self:Transmission( ATIS.Sound.MillimetersOfMercury, 0.1 ) + self:Transmission( self.Sound.MillimetersOfMercury, 0.1 ) else if self.metric then - self:Transmission( ATIS.Sound.HectoPascal, 0.1 ) + self:Transmission( self.Sound.HectoPascal, 0.1 ) else - self:Transmission( ATIS.Sound.InchesOfMercury, 0.1 ) + self:Transmission( self.Sound.InchesOfMercury, 0.1 ) end end end @@ -2614,7 +2616,9 @@ function ATIS:onafterBroadcast( From, Event, To ) -- Active runway. local subtitle = "" if runwayLanding then + local actrun = self.gettext:GetEntry("ACTIVELANDING",self.locale) + subtitle=string.format("%s %s", actrun, runwayLanding) if rwyLandingLeft==true then subtitle=subtitle.." "..self.gettext:GetEntry("LEFT",self.locale) @@ -2622,29 +2626,44 @@ function ATIS:onafterBroadcast( From, Event, To ) subtitle=subtitle.." "..self.gettext:GetEntry("RIGHT",self.locale) end alltext = alltext .. ";\n" .. subtitle - end + + if not self.useSRS then + self:Transmission(self.Sound.ActiveRunwayArrival, 1.0, subtitle) + self.radioqueue:Number2Transmission(runwayLanding) + if rwyLandingLeft==true then + self:Transmission(self.Sound.Left, 0.2) + elseif rwyLandingLeft==false then + self:Transmission(self.Sound.Right, 0.2) + end + end + + end + if runwayTakeoff then + local actrun = self.gettext:GetEntry("ACTIVERUN",self.locale) - --subtitle=string.format("Active runway %s", runwayLanding) + subtitle=string.format("%s %s", actrun, runwayTakeoff) if rwyTakeoffLeft==true then - --subtitle=subtitle.." Left" subtitle=subtitle.." "..self.gettext:GetEntry("LEFT",self.locale) elseif rwyTakeoffLeft==false then - --subtitle=subtitle.." Right" subtitle=subtitle.." "..self.gettext:GetEntry("RIGHT",self.locale) end + alltext = alltext .. ";\n" .. subtitle + + if not self.useSRS then + self:Transmission(self.Sound.ActiveRunwayDeparture, 1.0, subtitle) + self.radioqueue:Number2Transmission(runwayTakeoff) + if rwyTakeoffLeft==true then + self:Transmission(self.Sound.Left, 0.2) + elseif rwyTakeoffLeft==false then + self:Transmission(self.Sound.Right, 0.2) + end + end + + end _RUNACT = subtitle - if not self.useSRS then - self:Transmission(ATIS.Sound.ActiveRunway, 1.0, subtitle) - self.radioqueue:Number2Transmission(runwayLanding) - if rwyLandingLeft==true then - self:Transmission(ATIS.Sound.Left, 0.2) - elseif rwyLandingLeft==false then - self:Transmission(ATIS.Sound.Right, 0.2) - end - end alltext = alltext .. ";\n" .. subtitle -- Runway length. @@ -2673,19 +2692,19 @@ function ATIS:onafterBroadcast( From, Event, To ) -- Transmit. if not self.useSRS then - self:Transmission( ATIS.Sound.RunwayLength, 1.0, subtitle ) + self:Transmission( self.Sound.RunwayLength, 1.0, subtitle ) if tonumber( L1000 ) > 0 then self.radioqueue:Number2Transmission( L1000 ) - self:Transmission( ATIS.Sound.Thousand, 0.1 ) + self:Transmission( self.Sound.Thousand, 0.1 ) end if tonumber( L0100 ) > 0 then self.radioqueue:Number2Transmission( L0100 ) - self:Transmission( ATIS.Sound.Hundred, 0.1 ) + self:Transmission( self.Sound.Hundred, 0.1 ) end if self.metric then - self:Transmission( ATIS.Sound.Meters, 0.1 ) + self:Transmission( self.Sound.Meters, 0.1 ) else - self:Transmission( ATIS.Sound.Feet, 0.1 ) + self:Transmission( self.Sound.Feet, 0.1 ) end end alltext = alltext .. ";\n" .. subtitle @@ -2718,19 +2737,19 @@ function ATIS:onafterBroadcast( From, Event, To ) -- Transmit. if not self.useSRS then - self:Transmission( ATIS.Sound.Elevation, 1.0, subtitle ) + self:Transmission( self.Sound.Elevation, 1.0, subtitle ) if tonumber( L1000 ) > 0 then self.radioqueue:Number2Transmission( L1000 ) - self:Transmission( ATIS.Sound.Thousand, 0.1 ) + self:Transmission( self.Sound.Thousand, 0.1 ) end if tonumber( L0100 ) > 0 then self.radioqueue:Number2Transmission( L0100 ) - self:Transmission( ATIS.Sound.Hundred, 0.1 ) + self:Transmission( self.Sound.Hundred, 0.1 ) end if self.metric then - self:Transmission( ATIS.Sound.Meters, 0.1 ) + self:Transmission( self.Sound.Meters, 0.1 ) else - self:Transmission( ATIS.Sound.Feet, 0.1 ) + self:Transmission( self.Sound.Feet, 0.1 ) end end alltext = alltext .. ";\n" .. subtitle @@ -2749,16 +2768,16 @@ function ATIS:onafterBroadcast( From, Event, To ) --subtitle = string.format( "Tower frequency %s", freqs ) subtitle = string.format( "%s %s", twrfrq, freqs ) if not self.useSRS then - self:Transmission( ATIS.Sound.TowerFrequency, 1.0, subtitle ) + self:Transmission( self.Sound.TowerFrequency, 1.0, subtitle ) for _, freq in pairs( self.towerfrequency ) do local f = string.format( "%.3f", freq ) f = UTILS.Split( f, "." ) self.radioqueue:Number2Transmission( f[1], nil, 0.5 ) if tonumber( f[2] ) > 0 then - self:Transmission( ATIS.Sound.Decimal, 0.2 ) + self:Transmission( self.Sound.Decimal, 0.2 ) self.radioqueue:Number2Transmission( f[2] ) end - self:Transmission( ATIS.Sound.MegaHertz, 0.2 ) + self:Transmission( self.Sound.MegaHertz, 0.2 ) end end alltext = alltext .. ";\n" .. subtitle @@ -2771,15 +2790,15 @@ function ATIS:onafterBroadcast( From, Event, To ) --subtitle = string.format( "ILS frequency %.2f MHz", ils.frequency ) subtitle = string.format( "%s %.2f MHz", ilstxt, ils.frequency ) if not self.useSRS then - self:Transmission( ATIS.Sound.ILSFrequency, 1.0, subtitle ) + self:Transmission( self.Sound.ILSFrequency, 1.0, subtitle ) local f = string.format( "%.2f", ils.frequency ) f = UTILS.Split( f, "." ) self.radioqueue:Number2Transmission( f[1], nil, 0.5 ) if tonumber( f[2] ) > 0 then - self:Transmission( ATIS.Sound.Decimal, 0.2 ) + self:Transmission( self.Sound.Decimal, 0.2 ) self.radioqueue:Number2Transmission( f[2] ) end - self:Transmission( ATIS.Sound.MegaHertz, 0.2 ) + self:Transmission( self.Sound.MegaHertz, 0.2 ) end alltext = alltext .. ";\n" .. subtitle end @@ -2791,15 +2810,15 @@ function ATIS:onafterBroadcast( From, Event, To ) --subtitle = string.format( "Outer NDB frequency %.2f MHz", ndb.frequency ) subtitle = string.format( "%s %.2f MHz", ndbtxt, ndb.frequency ) if not self.useSRS then - self:Transmission( ATIS.Sound.OuterNDBFrequency, 1.0, subtitle ) + self:Transmission( self.Sound.OuterNDBFrequency, 1.0, subtitle ) local f = string.format( "%.2f", ndb.frequency ) f = UTILS.Split( f, "." ) self.radioqueue:Number2Transmission( f[1], nil, 0.5 ) if tonumber( f[2] ) > 0 then - self:Transmission( ATIS.Sound.Decimal, 0.2 ) + self:Transmission( self.Sound.Decimal, 0.2 ) self.radioqueue:Number2Transmission( f[2] ) end - self:Transmission( ATIS.Sound.MegaHertz, 0.2 ) + self:Transmission( self.Sound.MegaHertz, 0.2 ) end alltext = alltext .. ";\n" .. subtitle end @@ -2811,15 +2830,15 @@ function ATIS:onafterBroadcast( From, Event, To ) --subtitle = string.format( "Inner NDB frequency %.2f MHz", ndb.frequency ) subtitle = string.format( "%s %.2f MHz", ndbtxt, ndb.frequency ) if not self.useSRS then - self:Transmission( ATIS.Sound.InnerNDBFrequency, 1.0, subtitle ) + self:Transmission( self.Sound.InnerNDBFrequency, 1.0, subtitle ) local f = string.format( "%.2f", ndb.frequency ) f = UTILS.Split( f, "." ) self.radioqueue:Number2Transmission( f[1], nil, 0.5 ) if tonumber( f[2] ) > 0 then - self:Transmission( ATIS.Sound.Decimal, 0.2 ) + self:Transmission( self.Sound.Decimal, 0.2 ) self.radioqueue:Number2Transmission( f[2] ) end - self:Transmission( ATIS.Sound.MegaHertz, 0.2 ) + self:Transmission( self.Sound.MegaHertz, 0.2 ) end alltext = alltext .. ";\n" .. subtitle end @@ -2835,15 +2854,15 @@ function ATIS:onafterBroadcast( From, Event, To ) subtitle = string.format( "%s %.2f MHz", vorttstxt, self.vor ) end if not self.useSRS then - self:Transmission( ATIS.Sound.VORFrequency, 1.0, subtitle ) + self:Transmission( self.Sound.VORFrequency, 1.0, subtitle ) local f = string.format( "%.2f", self.vor ) f = UTILS.Split( f, "." ) self.radioqueue:Number2Transmission( f[1], nil, 0.5 ) if tonumber( f[2] ) > 0 then - self:Transmission( ATIS.Sound.Decimal, 0.2 ) + self:Transmission( self.Sound.Decimal, 0.2 ) self.radioqueue:Number2Transmission( f[2] ) end - self:Transmission( ATIS.Sound.MegaHertz, 0.2 ) + self:Transmission( self.Sound.MegaHertz, 0.2 ) end alltext = alltext .. ";\n" .. subtitle end @@ -2854,7 +2873,7 @@ function ATIS:onafterBroadcast( From, Event, To ) --subtitle=string.format("TACAN channel %dX Ray", self.tacan) subtitle=string.format(tactxt, self.tacan) if not self.useSRS then - self:Transmission( ATIS.Sound.TACANChannel, 1.0, subtitle ) + self:Transmission( self.Sound.TACANChannel, 1.0, subtitle ) self.radioqueue:Number2Transmission( tostring( self.tacan ), nil, 0.2 ) self.radioqueue:NewTransmission( "NATO Alphabet/Xray.ogg", 0.75, self.soundpath, nil, 0.2 ) end @@ -2867,7 +2886,7 @@ function ATIS:onafterBroadcast( From, Event, To ) --subtitle = string.format( "RSBN channel %d", self.rsbn ) subtitle = string.format( "%s %d", rsbntxt, self.rsbn ) if not self.useSRS then - self:Transmission( ATIS.Sound.RSBNChannel, 1.0, subtitle ) + self:Transmission( self.Sound.RSBNChannel, 1.0, subtitle ) self.radioqueue:Number2Transmission( tostring( self.rsbn ), nil, 0.2 ) end alltext = alltext .. ";\n" .. subtitle @@ -2880,7 +2899,7 @@ function ATIS:onafterBroadcast( From, Event, To ) --subtitle = string.format( "PRMG channel %d", ndb.frequency ) subtitle = string.format( "%s %d", prmtxt, ndb.frequency ) if not self.useSRS then - self:Transmission( ATIS.Sound.PRMGChannel, 1.0, subtitle ) + self:Transmission( self.Sound.PRMGChannel, 1.0, subtitle ) self.radioqueue:Number2Transmission( tostring( ndb.frequency ), nil, 0.5 ) end alltext = alltext .. ";\n" .. subtitle @@ -2896,7 +2915,7 @@ function ATIS:onafterBroadcast( From, Event, To ) --subtitle = string.format( "Advise on initial contact, you have information %s", NATO ) subtitle = string.format( "%s %s", advtxt, NATO ) if not self.useSRS then - self:Transmission( ATIS.Sound.AdviceOnInitial, 0.5, subtitle ) + self:Transmission( self.Sound.AdviceOnInitial, 0.5, subtitle ) self.radioqueue:NewTransmission( string.format( "NATO Alphabet/%s.ogg", NATO ), 0.75, self.soundpath ) end alltext = alltext .. ";\n" .. subtitle From 9ceb26c7b14aafdfdf565a9b3c5d1972573428c5 Mon Sep 17 00:00:00 2001 From: Frank Date: Mon, 1 Jul 2024 22:07:55 +0200 Subject: [PATCH 06/19] ATIS - Cleaned up debug lines --- Moose Development/Moose/Ops/ATIS.lua | 3 --- Moose Development/Moose/Utilities/Utils.lua | 22 +++++---------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index 2c68b127c..1b6a61e76 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -2073,8 +2073,6 @@ function ATIS:onafterBroadcast( From, Event, To ) -- Cloud preset (DCS 2.7) local cloudspreset = clouds.preset or "Nothing" - env.info("FF cloud preset "..cloudspreset) - -- Precepitation: 0=None, 1=Rain, 2=Thunderstorm, 3=Snow, 4=Snowstorm. local precepitation = 0 @@ -2102,7 +2100,6 @@ function ATIS:onafterBroadcast( From, Event, To ) else precepitation = 3 -- snow end - env.info("Fprecipt "..precepitation) elseif cloudspreset:find( "RainyPreset" ) then -- Overcast + Rain clouddens = 9 diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index 2f975920a..842c94df9 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -3998,23 +3998,20 @@ end -- @return #table The table filled with data from the csv file. function UTILS.ReadCSV(filename) - if not UTILS.FileExists(filename) then - + if not UTILS.FileExists(filename) then env.error("File does not exist") - return nil - + return nil end --- Function that load data from a file. local function _loadfile( filename ) local f = io.open( filename, "rb" ) if f then - -- self:I(self.lid..string.format("Loading player results from file %s", tostring(filename))) local data = f:read( "*all" ) f:close() return data else - BASE:E( self.lid .. string.format( "WARNING: Could not load player results from file %s. File might not exist just yet.", tostring( filename ) ) ) + BASE:E(string.format( "WARNING: Could read data from file %s!", tostring( filename ) ) ) return nil end end @@ -4032,9 +4029,7 @@ function UTILS.ReadCSV(filename) local sep=";" local columns=UTILS.Split(lines[1], sep) - - BASE:I(columns) - + -- Remove header line. table.remove(lines, 1) @@ -4046,16 +4041,9 @@ function UTILS.ReadCSV(filename) for j, value in pairs(UTILS.Split(line, sep)) do local key=string.gsub(columns[j], "[\n\r]","") - - - --env.info(string.format("i=%d, j=%d key=%s value=%s", i,j, key, value)) - - row[key]=value - + row[key]=value end table.insert(csvdata, row) - BASE:E(row) - end From 58139b34a884bbce2b9f74f0edfa150c5016b61e Mon Sep 17 00:00:00 2001 From: Frank Date: Mon, 1 Jul 2024 22:13:55 +0200 Subject: [PATCH 07/19] Update ATIS.lua - renamed function --- Moose Development/Moose/Ops/ATIS.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index 1b6a61e76..4a9a61f98 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -1110,7 +1110,7 @@ end -- @param #ATIS self -- @param #string csvfile Full path to the csv file on your local disk. -- @return #ATIS self -function ATIS:SetSoundfilesInfoFile( csvfile ) +function ATIS:SetSoundfilesInfo( csvfile ) --- Local function to return the ATIS.Soundfile for a given file name local function getSound(filename) From 77a1150037c4118ed1f255d334feebbe0491a3c0 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 2 Jul 2024 12:46:45 +0200 Subject: [PATCH 08/19] #EASYGCICAP - add options to set default despawn after holding or landing --- Moose Development/Moose/Ops/EasyGCICAP.lua | 48 ++++++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Ops/EasyGCICAP.lua b/Moose Development/Moose/Ops/EasyGCICAP.lua index e9db4aea1..06ae1d6ca 100644 --- a/Moose Development/Moose/Ops/EasyGCICAP.lua +++ b/Moose Development/Moose/Ops/EasyGCICAP.lua @@ -65,6 +65,8 @@ -- @field #boolean TankerInvisible -- @field #number CapFormation -- @field #table ReadyFlightGroups +-- @field #boolean DespawnAfterLanding +-- @field #boolean DespawnAfterHolding -- @extends Core.Fsm#FSM --- *“Airspeed, altitude, and brains. Two are always needed to successfully complete the flight.”* -- Unknown. @@ -209,6 +211,8 @@ EASYGCICAP = { TankerInvisible = true, CapFormation = nil, ReadyFlightGroups = {}, + DespawnAfterLanding = false, + DespawnAfterHolding = true, } --- Internal Squadron data type @@ -244,7 +248,7 @@ EASYGCICAP = { --- EASYGCICAP class version. -- @field #string version -EASYGCICAP.version="0.1.10" +EASYGCICAP.version="0.1.11" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -292,6 +296,8 @@ function EASYGCICAP:New(Alias, AirbaseName, Coalition, EWRName) self.Monitor = false self.TankerInvisible = true self.CapFormation = ENUMS.Formation.FixedWing.FingerFour.Group + self.DespawnAfterLanding = false + self.DespawnAfterHolding = true -- Set some string id for output to DCS.log file. self.lid=string.format("EASYGCICAP %s | ", self.alias) @@ -341,7 +347,7 @@ end -- @param #number Maxiumum Maxmimum number of parallel missions allowed. Count is Cap-Missions + Intercept-Missions + Alert5-Missionsm default is 6 -- @return #EASYGCICAP self function EASYGCICAP:SetMaxAliveMissions(Maxiumum) - self:T(self.lid.."SetDefaultResurrection") + self:T(self.lid.."SetMaxAliveMissions") self.MaxAliveMissions = Maxiumum or 8 return self end @@ -458,6 +464,26 @@ function EASYGCICAP:SetDefaultOverhead(Overhead) return self end +--- Set default despawning after landing. +-- @param #EASYGCICAP self +-- @return #EASYGCICAP self +function EASYGCICAP:SetDefaultDespawnAfterLanding() + self:T(self.lid.."SetDefaultDespawnAfterLanding") + self.DespawnAfterLanding = true + self.DespawnAfterHolding = false + return self +end + +--- Set default despawning after holding (despawn in air close to AFB). +-- @param #EASYGCICAP self +-- @return #EASYGCICAP self +function EASYGCICAP:SetDefaultDespawnAfterHolding() + self:T(self.lid.."SetDefaultDespawnAfterLanding") + self.DespawnAfterLanding = false + self.DespawnAfterHolding = true + return self +end + --- Set CAP mission start to vary randomly between Start end End seconds. -- @param #EASYGCICAP self -- @param #number Start @@ -512,6 +538,8 @@ function EASYGCICAP:_AddAirwing(Airbasename, Alias) self:T(self.lid.."_AddAirwing "..Airbasename) local CapFormation = self.CapFormation + local DespawnAfterLanding = self.DespawnAfterLanding + local DespawnAfterHolding = self.DespawnAfterHolding -- Create Airwing local CAP_Wing = AIRWING:New(Airbasename,Alias) @@ -553,8 +581,11 @@ function EASYGCICAP:_AddAirwing(Airbasename, Alias) function CAP_Wing:OnAfterFlightOnMission(From, Event, To, Flightgroup, Mission) local flightgroup = Flightgroup -- Ops.FlightGroup#FLIGHTGROUP - --flightgroup:SetDespawnAfterLanding() - flightgroup:SetDespawnAfterHolding() + if DespawnAfterLanding then + flightgroup:SetDespawnAfterLanding() + elseif DespawnAfterHolding then + flightgroup:SetDespawnAfterHolding() + end flightgroup:SetDestinationbase(AIRBASE:FindByName(Airbasename)) flightgroup:GetGroup():CommandEPLRS(true,5) flightgroup:GetGroup():SetOptionRadarUsingForContinousSearch() @@ -577,10 +608,11 @@ function EASYGCICAP:_AddAirwing(Airbasename, Alias) flightgroup:GetGroup():OptionROTEvadeFire() flightgroup:SetFuelLowRTB(true) Intel:AddAgent(flightgroup) - function flightgroup:OnAfterHolding(From,Event,To) - self:Despawn(1,true) - end - + if DespawnAfterHolding then + function flightgroup:OnAfterHolding(From,Event,To) + self:Despawn(1,true) + end + end end if self.noaltert5 > 0 then From 8e0446c594cba28d487703d2d12a37de2e9f7c93 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 2 Jul 2024 15:52:44 +0200 Subject: [PATCH 09/19] Update Range.lua - Fixed RANGE.MenuF10Root --- Moose Development/Moose/Functional/Range.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index 3472132b5..8c949c12e 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -3352,7 +3352,7 @@ function RANGE:_AddF10Commands( _unitName ) ------------------- -- _rangePath = missionCommands.addSubMenuForGroup(_gid, self.rangename, RANGE.MenuF10Root) - _rangePath = MENU_GROUP:New( group, "On the Range" ) + _rangePath = MENU_GROUP:New( group, "On the Range", RANGE.MenuF10Root ) else From 6083191f323d83f6c7781ce8d32e42a7b5016031 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 2 Jul 2024 18:02:33 +0200 Subject: [PATCH 10/19] Update Range.lua - Added `RANGE:SetSoundfilesInfo` --- Moose Development/Moose/Functional/Range.lua | 50 +++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index 3472132b5..afd390acf 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -593,13 +593,14 @@ RANGE.MenuF10Root = nil --- Range script version. -- @field #string version -RANGE.version = "2.7.3" +RANGE.version = "2.8.0" -- TODO list: -- TODO: Verbosity level for messages. -- TODO: Add option for default settings such as smoke off. -- TODO: Add custom weapons, which can be specified by the user. -- TODO: Check if units are still alive. +-- TODO: Option for custom sound files. -- DONE: Scenery as targets. -- DONE: Add statics for strafe pits. -- DONE: Add missiles. @@ -1327,6 +1328,53 @@ function RANGE:SetSoundfilesPath( path ) return self end +--- Set the path to the csv file that contains information about the used sound files. +-- The parameter file has to be located on your local disk (**not** inside the miz file). +-- @param #RANGE self +-- @param #string csvfile Full path to the csv file on your local disk. +-- @return #RANGE self +function RANGE:SetSoundfilesInfo( csvfile ) + + --- Local function to return the ATIS.Soundfile for a given file name + local function getSound(filename) + for key,_soundfile in pairs(self.Sound) do + local soundfile=_soundfile --#RANGE.Soundfile + if filename==soundfile.filename then + return soundfile + end + end + return nil + end + + -- Read csv file + local data=UTILS.ReadCSV(csvfile) + + if data then + + for i,sound in pairs(data) do + + -- Get the ATIS.Soundfile + local soundfile=getSound(sound.filename..".ogg") --#RANGE.Soundfile + + if soundfile then + + -- Set duration + soundfile.duration=tonumber(sound.duration) + + else + self:E(string.format("ERROR: Could not get info for sound file %s", sound.filename)) + end + + end + else + self:E(string.format("ERROR: Could not read sound csv file!")) + end + + + return self +end + + --- Add new strafe pit. For a strafe pit, hits from guns are counted. One pit can consist of several units. -- A strafe run approach is only valid if the player enters via a zone in front of the pit, which is defined by boxlength, boxwidth, and heading. -- Furthermore, the player must not be too high and fly in the direction of the pit to make a valid target apporoach. From 8958d7b71f6d7c149ace83a34612c28017e3a6be Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 2 Jul 2024 18:04:36 +0200 Subject: [PATCH 11/19] Update Range.lua Replaced RANGE.Sound. by self.Sound. --- Moose Development/Moose/Functional/Range.lua | 90 ++++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index afd390acf..6ee058fc7 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -859,16 +859,16 @@ function RANGE:onafterStart() self.rangecontrol.schedonce = true -- Init numbers. - self.rangecontrol:SetDigit( 0, RANGE.Sound.RC0.filename, RANGE.Sound.RC0.duration, self.soundpath ) - self.rangecontrol:SetDigit( 1, RANGE.Sound.RC1.filename, RANGE.Sound.RC1.duration, self.soundpath ) - self.rangecontrol:SetDigit( 2, RANGE.Sound.RC2.filename, RANGE.Sound.RC2.duration, self.soundpath ) - self.rangecontrol:SetDigit( 3, RANGE.Sound.RC3.filename, RANGE.Sound.RC3.duration, self.soundpath ) - self.rangecontrol:SetDigit( 4, RANGE.Sound.RC4.filename, RANGE.Sound.RC4.duration, self.soundpath ) - self.rangecontrol:SetDigit( 5, RANGE.Sound.RC5.filename, RANGE.Sound.RC5.duration, self.soundpath ) - self.rangecontrol:SetDigit( 6, RANGE.Sound.RC6.filename, RANGE.Sound.RC6.duration, self.soundpath ) - self.rangecontrol:SetDigit( 7, RANGE.Sound.RC7.filename, RANGE.Sound.RC7.duration, self.soundpath ) - self.rangecontrol:SetDigit( 8, RANGE.Sound.RC8.filename, RANGE.Sound.RC8.duration, self.soundpath ) - self.rangecontrol:SetDigit( 9, RANGE.Sound.RC9.filename, RANGE.Sound.RC9.duration, self.soundpath ) + self.rangecontrol:SetDigit( 0, self.Sound.RC0.filename, self.Sound.RC0.duration, self.soundpath ) + self.rangecontrol:SetDigit( 1, self.Sound.RC1.filename, self.Sound.RC1.duration, self.soundpath ) + self.rangecontrol:SetDigit( 2, self.Sound.RC2.filename, self.Sound.RC2.duration, self.soundpath ) + self.rangecontrol:SetDigit( 3, self.Sound.RC3.filename, self.Sound.RC3.duration, self.soundpath ) + self.rangecontrol:SetDigit( 4, self.Sound.RC4.filename, self.Sound.RC4.duration, self.soundpath ) + self.rangecontrol:SetDigit( 5, self.Sound.RC5.filename, self.Sound.RC5.duration, self.soundpath ) + self.rangecontrol:SetDigit( 6, self.Sound.RC6.filename, self.Sound.RC6.duration, self.soundpath ) + self.rangecontrol:SetDigit( 7, self.Sound.RC7.filename, self.Sound.RC7.duration, self.soundpath ) + self.rangecontrol:SetDigit( 8, self.Sound.RC8.filename, self.Sound.RC8.duration, self.soundpath ) + self.rangecontrol:SetDigit( 9, self.Sound.RC9.filename, self.Sound.RC9.duration, self.soundpath ) -- Set location where the messages are transmitted from. self.rangecontrol:SetSenderCoordinate( self.location ) @@ -885,16 +885,16 @@ function RANGE:onafterStart() self.instructor.schedonce = true -- Init numbers. - self.instructor:SetDigit( 0, RANGE.Sound.IR0.filename, RANGE.Sound.IR0.duration, self.soundpath ) - self.instructor:SetDigit( 1, RANGE.Sound.IR1.filename, RANGE.Sound.IR1.duration, self.soundpath ) - self.instructor:SetDigit( 2, RANGE.Sound.IR2.filename, RANGE.Sound.IR2.duration, self.soundpath ) - self.instructor:SetDigit( 3, RANGE.Sound.IR3.filename, RANGE.Sound.IR3.duration, self.soundpath ) - self.instructor:SetDigit( 4, RANGE.Sound.IR4.filename, RANGE.Sound.IR4.duration, self.soundpath ) - self.instructor:SetDigit( 5, RANGE.Sound.IR5.filename, RANGE.Sound.IR5.duration, self.soundpath ) - self.instructor:SetDigit( 6, RANGE.Sound.IR6.filename, RANGE.Sound.IR6.duration, self.soundpath ) - self.instructor:SetDigit( 7, RANGE.Sound.IR7.filename, RANGE.Sound.IR7.duration, self.soundpath ) - self.instructor:SetDigit( 8, RANGE.Sound.IR8.filename, RANGE.Sound.IR8.duration, self.soundpath ) - self.instructor:SetDigit( 9, RANGE.Sound.IR9.filename, RANGE.Sound.IR9.duration, self.soundpath ) + self.instructor:SetDigit( 0, self.Sound.IR0.filename, self.Sound.IR0.duration, self.soundpath ) + self.instructor:SetDigit( 1, self.Sound.IR1.filename, self.Sound.IR1.duration, self.soundpath ) + self.instructor:SetDigit( 2, self.Sound.IR2.filename, self.Sound.IR2.duration, self.soundpath ) + self.instructor:SetDigit( 3, self.Sound.IR3.filename, self.Sound.IR3.duration, self.soundpath ) + self.instructor:SetDigit( 4, self.Sound.IR4.filename, self.Sound.IR4.duration, self.soundpath ) + self.instructor:SetDigit( 5, self.Sound.IR5.filename, self.Sound.IR5.duration, self.soundpath ) + self.instructor:SetDigit( 6, self.Sound.IR6.filename, self.Sound.IR6.duration, self.soundpath ) + self.instructor:SetDigit( 7, self.Sound.IR7.filename, self.Sound.IR7.duration, self.soundpath ) + self.instructor:SetDigit( 8, self.Sound.IR8.filename, self.Sound.IR8.duration, self.soundpath ) + self.instructor:SetDigit( 9, self.Sound.IR9.filename, self.Sound.IR9.duration, self.soundpath ) -- Set location where the messages are transmitted from. self.instructor:SetSenderCoordinate( self.location ) @@ -2064,7 +2064,7 @@ function RANGE._OnImpact(weapon, self, playerData, attackHdg, attackAlt, attackV if self.useSRS then self.controlsrsQ:NewTransmission(_message,nil,self.controlmsrs,nil,1) else - self.rangecontrol:NewTransmission( RANGE.Sound.RCWeaponImpactedTooFar.filename, RANGE.Sound.RCWeaponImpactedTooFar.duration, self.soundpath, nil, nil, _message, self.subduration ) + self.rangecontrol:NewTransmission( self.Sound.RCWeaponImpactedTooFar.filename, self.Sound.RCWeaponImpactedTooFar.duration, self.soundpath, nil, nil, _message, self.subduration ) end end @@ -2211,15 +2211,15 @@ function RANGE:onafterEnterRange( From, Event, To, player ) -- Radio message that player entered the range -- You entered the bombing range. For hit assessment, contact the range controller at xy MHz - self.instructor:NewTransmission( RANGE.Sound.IREnterRange.filename, RANGE.Sound.IREnterRange.duration, self.soundpath ) + self.instructor:NewTransmission( self.Sound.IREnterRange.filename, self.Sound.IREnterRange.duration, self.soundpath ) self.instructor:Number2Transmission( RF[1] ) if tonumber( RF[2] ) > 0 then - self.instructor:NewTransmission( RANGE.Sound.IRDecimal.filename, RANGE.Sound.IRDecimal.duration, self.soundpath ) + self.instructor:NewTransmission( self.Sound.IRDecimal.filename, self.Sound.IRDecimal.duration, self.soundpath ) self.instructor:Number2Transmission( RF[2] ) end - self.instructor:NewTransmission( RANGE.Sound.IRMegaHertz.filename, RANGE.Sound.IRMegaHertz.duration, self.soundpath ) + self.instructor:NewTransmission( self.Sound.IRMegaHertz.filename, self.Sound.IRMegaHertz.duration, self.soundpath ) end end @@ -2255,7 +2255,7 @@ function RANGE:onafterExitRange( From, Event, To, player ) self.instructsrsQ:NewTransmission(text, nil, self.instructmsrs, nil, 1, {player.client:GetGroup()}, text, 10) else - self.instructor:NewTransmission( RANGE.Sound.IRExitRange.filename, RANGE.Sound.IRExitRange.duration, self.soundpath ) + self.instructor:NewTransmission( self.Sound.IRExitRange.filename, self.Sound.IRExitRange.duration, self.soundpath ) end end @@ -2291,20 +2291,20 @@ function RANGE:onafterImpact( From, Event, To, result, player ) local group = player.client:GetGroup() self.controlsrsQ:NewTransmission(text,nil,self.controlmsrs,nil,1,{group},text,10) else - self.rangecontrol:NewTransmission( RANGE.Sound.RCImpact.filename, RANGE.Sound.RCImpact.duration, self.soundpath, nil, nil, text, self.subduration ) + self.rangecontrol:NewTransmission( self.Sound.RCImpact.filename, self.Sound.RCImpact.duration, self.soundpath, nil, nil, text, self.subduration ) self.rangecontrol:Number2Transmission( string.format( "%03d", result.radial ), nil, 0.1 ) - self.rangecontrol:NewTransmission( RANGE.Sound.RCDegrees.filename, RANGE.Sound.RCDegrees.duration, self.soundpath ) - self.rangecontrol:NewTransmission( RANGE.Sound.RCFor.filename, RANGE.Sound.RCFor.duration, self.soundpath ) + self.rangecontrol:NewTransmission( self.Sound.RCDegrees.filename, self.Sound.RCDegrees.duration, self.soundpath ) + self.rangecontrol:NewTransmission( self.Sound.RCFor.filename, self.Sound.RCFor.duration, self.soundpath ) self.rangecontrol:Number2Transmission( string.format( "%d", UTILS.MetersToFeet( result.distance ) ) ) - self.rangecontrol:NewTransmission( RANGE.Sound.RCFeet.filename, RANGE.Sound.RCFeet.duration, self.soundpath ) + self.rangecontrol:NewTransmission( self.Sound.RCFeet.filename, self.Sound.RCFeet.duration, self.soundpath ) if result.quality == "POOR" then - self.rangecontrol:NewTransmission( RANGE.Sound.RCPoorHit.filename, RANGE.Sound.RCPoorHit.duration, self.soundpath, nil, 0.5 ) + self.rangecontrol:NewTransmission( self.Sound.RCPoorHit.filename, self.Sound.RCPoorHit.duration, self.soundpath, nil, 0.5 ) elseif result.quality == "INEFFECTIVE" then - self.rangecontrol:NewTransmission( RANGE.Sound.RCIneffectiveHit.filename, RANGE.Sound.RCIneffectiveHit.duration, self.soundpath, nil, 0.5 ) + self.rangecontrol:NewTransmission( self.Sound.RCIneffectiveHit.filename, self.Sound.RCIneffectiveHit.duration, self.soundpath, nil, 0.5 ) elseif result.quality == "GOOD" then - self.rangecontrol:NewTransmission( RANGE.Sound.RCGoodHit.filename, RANGE.Sound.RCGoodHit.duration, self.soundpath, nil, 0.5 ) + self.rangecontrol:NewTransmission( self.Sound.RCGoodHit.filename, self.Sound.RCGoodHit.duration, self.soundpath, nil, 0.5 ) elseif result.quality == "EXCELLENT" then - self.rangecontrol:NewTransmission( RANGE.Sound.RCExcellentHit.filename, RANGE.Sound.RCExcellentHit.duration, self.soundpath, nil, 0.5 ) + self.rangecontrol:NewTransmission( self.Sound.RCExcellentHit.filename, self.Sound.RCExcellentHit.duration, self.soundpath, nil, 0.5 ) end end end @@ -3200,7 +3200,7 @@ function RANGE:_CheckInZone( _unitName ) self.controlsrsQ:NewTransmission(text,nil,self.controlmsrs,nil,1) else -- You left the strafing zone too quickly! No score! - self.rangecontrol:NewTransmission( RANGE.Sound.RCLeftStrafePitTooQuickly.filename, RANGE.Sound.RCLeftStrafePitTooQuickly.duration, self.soundpath ) + self.rangecontrol:NewTransmission( self.Sound.RCLeftStrafePitTooQuickly.filename, self.Sound.RCLeftStrafePitTooQuickly.duration, self.soundpath ) end end else @@ -3227,23 +3227,23 @@ function RANGE:_CheckInZone( _unitName ) local resulttext="" if _result.pastfoulline == true then -- resulttext = "* INVALID - PASSED FOUL LINE *" - _sound = RANGE.Sound.RCPoorPass -- + _sound = self.Sound.RCPoorPass -- else if accur >= 90 then resulttext = "DEADEYE PASS" - _sound = RANGE.Sound.RCExcellentPass + _sound = self.Sound.RCExcellentPass elseif accur >= 75 then resulttext = "EXCELLENT PASS" - _sound = RANGE.Sound.RCExcellentPass + _sound = self.Sound.RCExcellentPass elseif accur >= 50 then resulttext = "GOOD PASS" - _sound = RANGE.Sound.RCGoodPass + _sound = self.Sound.RCGoodPass elseif accur >= 25 then resulttext = "INEFFECTIVE PASS" - _sound = RANGE.Sound.RCIneffectivePass + _sound = self.Sound.RCIneffectivePass else resulttext = "POOR PASS" - _sound = RANGE.Sound.RCPoorPass + _sound = self.Sound.RCPoorPass end end @@ -3290,14 +3290,14 @@ function RANGE:_CheckInZone( _unitName ) if self.useSRS then self.controlsrsQ:NewTransmission(ttstext,nil,self.controlmsrs,nil,1) else - self.rangecontrol:NewTransmission( RANGE.Sound.RCHitsOnTarget.filename, RANGE.Sound.RCHitsOnTarget.duration, self.soundpath ) + self.rangecontrol:NewTransmission( self.Sound.RCHitsOnTarget.filename, self.Sound.RCHitsOnTarget.duration, self.soundpath ) self.rangecontrol:Number2Transmission( string.format( "%d", _result.hits ) ) if shots and accur then - self.rangecontrol:NewTransmission( RANGE.Sound.RCTotalRoundsFired.filename, RANGE.Sound.RCTotalRoundsFired.duration, self.soundpath, nil, 0.2 ) + self.rangecontrol:NewTransmission( self.Sound.RCTotalRoundsFired.filename, self.Sound.RCTotalRoundsFired.duration, self.soundpath, nil, 0.2 ) self.rangecontrol:Number2Transmission( string.format( "%d", shots ), nil, 0.2 ) - self.rangecontrol:NewTransmission( RANGE.Sound.RCAccuracy.filename, RANGE.Sound.RCAccuracy.duration, self.soundpath, nil, 0.2 ) + self.rangecontrol:NewTransmission( self.Sound.RCAccuracy.filename, self.Sound.RCAccuracy.duration, self.soundpath, nil, 0.2 ) self.rangecontrol:Number2Transmission( string.format( "%d", UTILS.Round( accur, 0 ) ) ) - self.rangecontrol:NewTransmission( RANGE.Sound.RCPercent.filename, RANGE.Sound.RCPercent.duration, self.soundpath ) + self.rangecontrol:NewTransmission( self.Sound.RCPercent.filename, self.Sound.RCPercent.duration, self.soundpath ) end self.rangecontrol:NewTransmission( _sound.filename, _sound.duration, self.soundpath, nil, 0.5 ) end @@ -3342,7 +3342,7 @@ function RANGE:_CheckInZone( _unitName ) if self.useSRS then self.controlsrsQ:NewTransmission(_msg,nil,self.controlmsrs,nil,1) else - self.rangecontrol:NewTransmission( RANGE.Sound.RCRollingInOnStrafeTarget.filename, RANGE.Sound.RCRollingInOnStrafeTarget.duration, self.soundpath ) + self.rangecontrol:NewTransmission( self.Sound.RCRollingInOnStrafeTarget.filename, self.Sound.RCRollingInOnStrafeTarget.duration, self.soundpath ) end end From edf7f4677c2c0d7c3fdee329b16a6dced5a9436c Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 3 Jul 2024 09:46:51 +0200 Subject: [PATCH 12/19] Update Range.lua - Fixed name of mission menu - Improved AddBombingTargetGroup to be passed as string --- Moose Development/Moose/Functional/Range.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index 8c949c12e..4141388ab 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -1665,12 +1665,16 @@ end --- Add all units of a group as bombing targets. -- @param #RANGE self --- @param Wrapper.Group#GROUP group Group of bombing targets. +-- @param Wrapper.Group#GROUP group Group of bombing targets. Can also be given as group name. -- @param #number goodhitrange Max distance from unit which is considered as a good hit. -- @param #boolean randommove If true, unit will move randomly within the range. Default is false. -- @return #RANGE self function RANGE:AddBombingTargetGroup( group, goodhitrange, randommove ) self:F( { group = group, goodhitrange = goodhitrange, randommove = randommove } ) + + if group and type(group)=="string" then + group=GROUP:FindByName(group) + end if group then @@ -3351,8 +3355,9 @@ function RANGE:_AddF10Commands( _unitName ) -- MISSION LEVEL -- ------------------- + -- Main F10 menu: F10// -- _rangePath = missionCommands.addSubMenuForGroup(_gid, self.rangename, RANGE.MenuF10Root) - _rangePath = MENU_GROUP:New( group, "On the Range", RANGE.MenuF10Root ) + _rangePath = MENU_GROUP:New( group, self.rangename, RANGE.MenuF10Root ) else @@ -3365,8 +3370,10 @@ function RANGE:_AddF10Commands( _unitName ) -- RANGE.MenuF10[_gid]=missionCommands.addSubMenuForGroup(_gid, "On the Range") RANGE.MenuF10[_gid] = MENU_GROUP:New( group, "On the Range" ) end + -- _rangePath = missionCommands.addSubMenuForGroup(_gid, self.rangename, RANGE.MenuF10[_gid]) _rangePath = MENU_GROUP:New( group, self.rangename, RANGE.MenuF10[_gid] ) + end local _statsPath = MENU_GROUP:New( group, "Statistics", _rangePath ) From 42979093b89f84727b28d5cebb7dd0ed222c5a6e Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 3 Jul 2024 17:45:21 +0200 Subject: [PATCH 13/19] Update Range.lua - Added `RANGE:SetMenuRoot` --- Moose Development/Moose/Functional/Range.lua | 40 ++++++++++++++------ 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index 4141388ab..121e13965 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -106,6 +106,7 @@ -- @field Sound.SRS#MSRS instructmsrs SRS wrapper for range instructor. -- @field Sound.SRS#MSRSQUEUE instructsrsQ SRS queue for range instructor. -- @field #number Coalition Coalition side for the menu, if any. +-- @field Core.Menu#MENU_MISSION menuF10root Specific user defined root F10 menu. -- @extends Core.Fsm#FSM --- *Don't only practice your art, but force your way into its secrets; art deserves that, for it and knowledge can raise man to the Divine.* - Ludwig van Beethoven @@ -927,6 +928,16 @@ end -- User Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +--- Set the root F10 menu under which the range F10 menu is created. +-- @param #RANGE self +-- @param Core.Menu#MENU_MISSION menu The root F10 menu. +-- @return #RANGE self +function RANGE:SetMenuRoot(menu) + self.menuF10root=menu + return self +end + + --- Set maximal strafing altitude. Player entering a strafe pit above that altitude are not registered for a valid pass. -- @param #RANGE self -- @param #number maxalt Maximum altitude in meters AGL. Default is 914 m = 3000 ft. @@ -3347,17 +3358,21 @@ function RANGE:_AddF10Commands( _unitName ) self.MenuAddedTo[_gid] = true -- Range root menu path. - local _rangePath = nil - - if RANGE.MenuF10Root then + local _rootMenu = nil + if self.menuF10root then + ------------------- -- MISSION LEVEL -- - ------------------- + ------------------- + + _rootMenu = MENU_GROUP:New( group, self.rangename, self.menuF10root ) + self:T2(self.lid..string.format("Creating F10 menu for group %s", group:GetName())) + + elseif RANGE.MenuF10Root then -- Main F10 menu: F10// - -- _rangePath = missionCommands.addSubMenuForGroup(_gid, self.rangename, RANGE.MenuF10Root) - _rangePath = MENU_GROUP:New( group, self.rangename, RANGE.MenuF10Root ) + _rootMenu = MENU_GROUP:New( group, self.rangename, RANGE.MenuF10Root ) else @@ -3367,14 +3382,17 @@ function RANGE:_AddF10Commands( _unitName ) -- Main F10 menu: F10/On the Range// if RANGE.MenuF10[_gid] == nil then - -- RANGE.MenuF10[_gid]=missionCommands.addSubMenuForGroup(_gid, "On the Range") - RANGE.MenuF10[_gid] = MENU_GROUP:New( group, "On the Range" ) + self:T2(self.lid..string.format("Creating F10 menu 'On the Range' for group %s", group:GetName())) + else + self:T2(self.lid..string.format("F10 menu 'On the Range' already EXISTS for group %s", group:GetName())) end - -- _rangePath = missionCommands.addSubMenuForGroup(_gid, self.rangename, RANGE.MenuF10[_gid]) - _rangePath = MENU_GROUP:New( group, self.rangename, RANGE.MenuF10[_gid] ) - + _rootMenu=RANGE.MenuF10[_gid] or MENU_GROUP:New( group, "On the Range" ) + end + + -- Range menu + local _rangePath = MENU_GROUP:New( group, self.rangename, _rootMenu ) local _statsPath = MENU_GROUP:New( group, "Statistics", _rangePath ) local _markPath = MENU_GROUP:New( group, "Mark Targets", _rangePath ) From 84dd1fa21c2c0846c183f25917fac6b25d75e4c5 Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 3 Jul 2024 23:17:37 +0200 Subject: [PATCH 14/19] Update Range.lua - Fixe F10 menu bug --- Moose Development/Moose/Functional/Range.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index 121e13965..87604b1b9 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -3366,13 +3366,15 @@ function RANGE:_AddF10Commands( _unitName ) -- MISSION LEVEL -- ------------------- - _rootMenu = MENU_GROUP:New( group, self.rangename, self.menuF10root ) + --_rootMenu = MENU_GROUP:New( group, self.rangename, self.menuF10root ) + _rootMenu = self.menuF10root self:T2(self.lid..string.format("Creating F10 menu for group %s", group:GetName())) elseif RANGE.MenuF10Root then -- Main F10 menu: F10// - _rootMenu = MENU_GROUP:New( group, self.rangename, RANGE.MenuF10Root ) + --_rootMenu = MENU_GROUP:New( group, self.rangename, RANGE.MenuF10Root ) + _rootMenu = RANGE.MenuF10Root else From 55a9c7e020b1392674ef584f82321189c11bc5ae Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 5 Jul 2024 17:53:50 +0200 Subject: [PATCH 15/19] Update Event.lua #2143 --- Moose Development/Moose/Core/Event.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Core/Event.lua b/Moose Development/Moose/Core/Event.lua index 78b69202a..98086d0d8 100644 --- a/Moose Development/Moose/Core/Event.lua +++ b/Moose Development/Moose/Core/Event.lua @@ -1346,7 +1346,7 @@ function EVENT:onEvent( Event ) -- Weapon. if Event.weapon then Event.Weapon = Event.weapon - Event.WeaponName = Event.Weapon:getTypeName() + Event.WeaponName = Event.weapon.getTypeName and Event.weapon:getTypeName() or "Unknown Weapon" Event.WeaponUNIT = CLIENT:Find( Event.Weapon, '', true ) -- Sometimes, the weapon is a player unit! Event.WeaponPlayerName = Event.WeaponUNIT and Event.Weapon.getPlayerName and Event.Weapon:getPlayerName() --Event.WeaponPlayerName = Event.WeaponUNIT and Event.Weapon:getPlayerName() From 29a4f7c160dd09ea9e9482103d0162e4517b52b1 Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 5 Jul 2024 21:35:55 +0200 Subject: [PATCH 16/19] Update Event.lua #2143 Try with isExist --- Moose Development/Moose/Core/Event.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Core/Event.lua b/Moose Development/Moose/Core/Event.lua index 98086d0d8..0f5320ff8 100644 --- a/Moose Development/Moose/Core/Event.lua +++ b/Moose Development/Moose/Core/Event.lua @@ -1346,7 +1346,7 @@ function EVENT:onEvent( Event ) -- Weapon. if Event.weapon then Event.Weapon = Event.weapon - Event.WeaponName = Event.weapon.getTypeName and Event.weapon:getTypeName() or "Unknown Weapon" + Event.WeaponName = Event.weapon:isExist() and Event.weapon:getTypeName() or "Unknown Weapon" Event.WeaponUNIT = CLIENT:Find( Event.Weapon, '', true ) -- Sometimes, the weapon is a player unit! Event.WeaponPlayerName = Event.WeaponUNIT and Event.Weapon.getPlayerName and Event.Weapon:getPlayerName() --Event.WeaponPlayerName = Event.WeaponUNIT and Event.Weapon:getPlayerName() From 13b272b6e53ad17a17714d9e40ced6457d93d1d3 Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 6 Jul 2024 21:48:07 +0200 Subject: [PATCH 17/19] Update Range.lua Allow zone to be a string in RANGE:SetRangeZone --- Moose Development/Moose/Functional/Range.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index 2911dafa6..77688b0da 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -1078,6 +1078,9 @@ end -- @param Core.Zone#ZONE zone MOOSE zone defining the range perimeters. -- @return #RANGE self function RANGE:SetRangeZone( zone ) + if zone and type(zone)=="string" then + zone=ZONE:FindByName(zone) + end self.rangezone = zone return self end From 6f3d9a497a0d4f03bc5805b0076082691bba1325 Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 6 Jul 2024 21:51:20 +0200 Subject: [PATCH 18/19] Update Chief.lua - Added unsupported mission type for OPSZONE to error log output --- Moose Development/Moose/Ops/Chief.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Ops/Chief.lua b/Moose Development/Moose/Ops/Chief.lua index b5ed5647c..0592046df 100644 --- a/Moose Development/Moose/Ops/Chief.lua +++ b/Moose Development/Moose/Ops/Chief.lua @@ -3240,7 +3240,7 @@ function CHIEF:RecruitAssetsForZone(StratZone, Resource) else -- Mission not supported. - self:E(self.lid..string.format("ERROR: Mission type not supported for OPSZONE! Unrecruiting assets...")) + self:E(self.lid..string.format("ERROR: Mission type %s not supported for OPSZONE! Unrecruiting assets...", tostring(MissionType))) LEGION.UnRecruitAssets(assets) return false From b215d0e7d48a1ebe3bf7a7d0790d8f518e0f7abe Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 7 Jul 2024 11:03:03 +0200 Subject: [PATCH 19/19] Update Range.lua - reduced initial status update --- Moose Development/Moose/Functional/Range.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index 77688b0da..eb3fc4f28 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -922,7 +922,7 @@ function RANGE:onafterStart() self.rangezone:SmokeZone( SMOKECOLOR.White ) end - self:__Status( -60 ) + self:__Status( -10 ) end -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------