From 06c3f7998b465ac46f3b69beac8a9b79aae2273a Mon Sep 17 00:00:00 2001 From: Applevangelist <72444570+Applevangelist@users.noreply.github.com> Date: Mon, 7 Jun 2021 15:09:30 +0200 Subject: [PATCH 1/6] Added function for message duration (#1542) ... and correct flash status setting --- .../Moose/Tasking/CommandCenter.lua | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Moose Development/Moose/Tasking/CommandCenter.lua b/Moose Development/Moose/Tasking/CommandCenter.lua index 0673facb1..2bcfe972c 100644 --- a/Moose Development/Moose/Tasking/CommandCenter.lua +++ b/Moose Development/Moose/Tasking/CommandCenter.lua @@ -202,6 +202,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName ) self:SetAutoAcceptTasks( true ) self:SetAutoAssignMethod( COMMANDCENTER.AutoAssignMethods.Distance ) self:SetFlashStatus( false ) + self:SetMessageDuration(10) self:HandleEvent( EVENTS.Birth, --- @param #COMMANDCENTER self @@ -682,7 +683,7 @@ end -- @param #string Message The message text. function COMMANDCENTER:MessageToAll( Message ) - self:GetPositionable():MessageToAll( Message, 20, self:GetName() ) + self:GetPositionable():MessageToAll( Message, self.MessageDuration, self:GetName() ) end @@ -692,7 +693,7 @@ end -- @param Wrapper.Group#GROUP MessageGroup The group to receive the message. function COMMANDCENTER:MessageToGroup( Message, MessageGroup ) - self:GetPositionable():MessageToGroup( Message, 15, MessageGroup, self:GetShortText() ) + self:GetPositionable():MessageToGroup( Message, self.MessageDuration, MessageGroup, self:GetShortText() ) end @@ -715,7 +716,7 @@ function COMMANDCENTER:MessageToCoalition( Message ) local CCCoalition = self:GetPositionable():GetCoalition() --TODO: Fix coalition bug! - self:GetPositionable():MessageToCoalition( Message, 15, CCCoalition, self:GetShortText() ) + self:GetPositionable():MessageToCoalition( Message, self.MessageDuration, CCCoalition, self:GetShortText() ) end @@ -795,9 +796,18 @@ end --- Let the command center flash a report of the status of the subscribed task to a group. -- @param #COMMANDCENTER self +-- @param Flash #boolean function COMMANDCENTER:SetFlashStatus( Flash ) self:F() - self.FlashStatus = Flash or true - + self.FlashStatus = Flash and true +end + +--- Duration a command center message is shown. +-- @param #COMMANDCENTER self +-- @param seconds #number +function COMMANDCENTER:SetMessageDuration(seconds) + self:F() + + self.MessageDuration = 10 or seconds end From 82d78c98bba379ce491da3e28744c38cfb9f84e9 Mon Sep 17 00:00:00 2001 From: Applevangelist <72444570+Applevangelist@users.noreply.github.com> Date: Mon, 7 Jun 2021 15:16:04 +0200 Subject: [PATCH 2/6] Update Spawn.lua (#1544) --- Moose Development/Moose/Core/Spawn.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Core/Spawn.lua b/Moose Development/Moose/Core/Spawn.lua index 89d6d681c..c865f5dbc 100644 --- a/Moose Development/Moose/Core/Spawn.lua +++ b/Moose Development/Moose/Core/Spawn.lua @@ -3406,10 +3406,10 @@ function SPAWN:_SpawnCleanUpScheduler() self:T( { SpawnUnitName, Stamp } ) if Stamp.Vec2 then - if SpawnUnit:InAir() == false and SpawnUnit:GetVelocityKMH() < 1 then + if (Stamp.Vec2.x == NewVec2.x and Stamp.Vec2.y == NewVec2.y) or (SpawnUnit:GetLife() <= 1) then local NewVec2 = SpawnUnit:GetVec2() if Stamp.Vec2.x == NewVec2.x and Stamp.Vec2.y == NewVec2.y then - -- If the plane is not moving, and is on the ground, assign it with a timestamp... + -- If the plane is not moving or dead, and is on the ground, assign it with a timestamp... if Stamp.Time + self.SpawnCleanUpInterval < timer.getTime() then self:T( { "CleanUp Scheduler:", "ReSpawning:", SpawnGroup:GetName() } ) self:ReSpawn( SpawnCursor ) From 858b00336bdb744de5f20420b94d1d75e0279bf1 Mon Sep 17 00:00:00 2001 From: Applevangelist <72444570+Applevangelist@users.noreply.github.com> Date: Mon, 7 Jun 2021 18:07:14 +0200 Subject: [PATCH 3/6] Update Spawn.lua --- Moose Development/Moose/Core/Spawn.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Moose Development/Moose/Core/Spawn.lua b/Moose Development/Moose/Core/Spawn.lua index c865f5dbc..d25186b66 100644 --- a/Moose Development/Moose/Core/Spawn.lua +++ b/Moose Development/Moose/Core/Spawn.lua @@ -3406,10 +3406,10 @@ function SPAWN:_SpawnCleanUpScheduler() self:T( { SpawnUnitName, Stamp } ) if Stamp.Vec2 then - if (Stamp.Vec2.x == NewVec2.x and Stamp.Vec2.y == NewVec2.y) or (SpawnUnit:GetLife() <= 1) then + if SpawnUnit:InAir() == false and SpawnUnit:GetVelocityKMH() < 1 then local NewVec2 = SpawnUnit:GetVec2() - if Stamp.Vec2.x == NewVec2.x and Stamp.Vec2.y == NewVec2.y then - -- If the plane is not moving or dead, and is on the ground, assign it with a timestamp... + if (Stamp.Vec2.x == NewVec2.x and Stamp.Vec2.y == NewVec2.y) or (SpawnUnit:GetLife() <= 1) then + -- If the plane is not moving or dead , and is on the ground, assign it with a timestamp... if Stamp.Time + self.SpawnCleanUpInterval < timer.getTime() then self:T( { "CleanUp Scheduler:", "ReSpawning:", SpawnGroup:GetName() } ) self:ReSpawn( SpawnCursor ) @@ -3427,7 +3427,7 @@ function SPAWN:_SpawnCleanUpScheduler() else if SpawnUnit:InAir() == false then Stamp.Vec2 = SpawnUnit:GetVec2() - if SpawnUnit:GetVelocityKMH() < 1 then + if (SpawnUnit:GetVelocityKMH() < 1) then Stamp.Time = timer.getTime() end else From 4fa525a4aedf419885cb9d0d2646dad39178fa27 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 8 Jun 2021 22:06:33 +0200 Subject: [PATCH 4/6] Update Airbase.lua --- Moose Development/Moose/Wrapper/Airbase.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Wrapper/Airbase.lua b/Moose Development/Moose/Wrapper/Airbase.lua index 220e3a254..55f5cc632 100644 --- a/Moose Development/Moose/Wrapper/Airbase.lua +++ b/Moose Development/Moose/Wrapper/Airbase.lua @@ -1391,7 +1391,8 @@ function AIRBASE:GetRunwayData(magvar, mark) name==AIRBASE.PersianGulf.Abu_Dhabi_International_Airport or name==AIRBASE.PersianGulf.Dubai_Intl or name==AIRBASE.PersianGulf.Shiraz_International_Airport or - name==AIRBASE.PersianGulf.Kish_International_Airport then + name==AIRBASE.PersianGulf.Kish_International_Airport or + name==AIRBASE.MarianaIslands.Andersen then -- 1-->4, 2-->3, 3-->2, 4-->1 exception=1 From 0c9390914ae491680c9b9d602b7419f9f333aef8 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 8 Jun 2021 23:51:03 +0200 Subject: [PATCH 5/6] Update SRS.lua --- Moose Development/Moose/Sound/SRS.lua | 51 +++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Sound/SRS.lua b/Moose Development/Moose/Sound/SRS.lua index 6260c62ca..d4e4ad2f7 100644 --- a/Moose Development/Moose/Sound/SRS.lua +++ b/Moose Development/Moose/Sound/SRS.lua @@ -319,11 +319,19 @@ function MSRS:PlaySoundFile(Soundfile, Delay) -- Append file. command=command.." --file="..tostring(soundfile) + self:_ExectCommand(command) + + --[[ + + command=command.." > bla.txt" + -- Debug output. self:I(string.format("MSRS PlaySoundfile command=%s", command)) -- Execute SRS command. local x=os.execute(command) + + ]] end @@ -347,11 +355,17 @@ function MSRS:PlaySoundText(SoundText, Delay) -- Append text. command=command..string.format(" --text=\"%s\"", tostring(SoundText.text)) + self:_ExectCommand(command) + + --[[ + command=command.." > bla.txt" + -- Debug putput. self:I(string.format("MSRS PlaySoundfile command=%s", command)) -- Execute SRS command. local x=os.execute(command) + ]] end @@ -375,6 +389,10 @@ function MSRS:PlayText(Text, Delay) -- Append text. command=command..string.format(" --text=\"%s\"", tostring(Text)) + self:_ExectCommand(command) + + --[[ + -- Check that length of command is max 255 chars or os.execute() will not work! if string.len(command)>255 then @@ -403,7 +421,7 @@ function MSRS:PlayText(Text, Delay) end - + ]] end return self @@ -441,7 +459,8 @@ function MSRS:PlayTextFile(TextFile, Delay) local l=string.len(command) -- Execute SRS command. - local x=os.execute(command) + self:_ExectCommand(command) +-- local x=os.execute(command) end @@ -453,6 +472,32 @@ end -- Misc Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +--- Execute SRS command to play sound using the `DCS-SR-ExternalAudio.exe`. +-- @param #MSRS self +-- @param #string command Command to executer +-- @return #string Command. +function MSRS:_ExectCommand(command) + + -- Create a tmp file. + local filename = os.getenv('TMP') .. "\\MSRS-"..STTS.uuid()..".bat" + + local script = io.open(filename, "w+") + script:write(command.." && exit") + script:close() + + -- Play command. + command=string.format('start /b "" "\"%s\"', filename) + + -- Play file in 0.05 seconds + timer.scheduleFunction(os.execute, command, timer.getTime()+0.01) + + -- Remove file in 1 second. + timer.scheduleFunction(os.remove, filename, timer.getTime()+1) + + return res +end + + --- Get SRS command to play sound using the `DCS-SR-ExternalAudio.exe`. -- @param #MSRS self -- @param #table freqs Frequencies in MHz. @@ -488,6 +533,8 @@ function MSRS:_GetCommand(freqs, modus, coal, gender, voice, culture, volume, sp -- Command from orig STTS script. Works better for some unknown reason! local command=string.format("start /min \"\" /d \"%s\" /b \"%s\" -f %s -m %s -c %s -p %s -n \"%s\" -h", path, exe, freqs, modus, coal, port, "ROBOT") + + --local command=string.format('start /b "" /d "%s" "%s" -f %s -m %s -c %s -p %s -n "%s" > bla.txt', path, exe, freqs, modus, coal, port, "ROBOT") -- Set voice or gender/culture. if voice then From 8a44fae3d4367cf7b9af3b50dcbd34d0e84839a7 Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 9 Jun 2021 13:01:48 +0200 Subject: [PATCH 6/6] Update SRS.lua - VBS script --- Moose Development/Moose/Sound/SRS.lua | 67 ++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/Moose Development/Moose/Sound/SRS.lua b/Moose Development/Moose/Sound/SRS.lua index d4e4ad2f7..069ee3d34 100644 --- a/Moose Development/Moose/Sound/SRS.lua +++ b/Moose Development/Moose/Sound/SRS.lua @@ -319,7 +319,7 @@ function MSRS:PlaySoundFile(Soundfile, Delay) -- Append file. command=command.." --file="..tostring(soundfile) - self:_ExectCommand(command) + self:_ExecCommand(command) --[[ @@ -355,7 +355,7 @@ function MSRS:PlaySoundText(SoundText, Delay) -- Append text. command=command..string.format(" --text=\"%s\"", tostring(SoundText.text)) - self:_ExectCommand(command) + self:_ExecCommand(command) --[[ command=command.." > bla.txt" @@ -389,7 +389,7 @@ function MSRS:PlayText(Text, Delay) -- Append text. command=command..string.format(" --text=\"%s\"", tostring(Text)) - self:_ExectCommand(command) + self:_ExecCommand(command) --[[ @@ -459,7 +459,7 @@ function MSRS:PlayTextFile(TextFile, Delay) local l=string.len(command) -- Execute SRS command. - self:_ExectCommand(command) + self:_ExecCommand(command) -- local x=os.execute(command) end @@ -476,7 +476,7 @@ end -- @param #MSRS self -- @param #string command Command to executer -- @return #string Command. -function MSRS:_ExectCommand(command) +function MSRS:_ExecCommand(command) -- Create a tmp file. local filename = os.getenv('TMP') .. "\\MSRS-"..STTS.uuid()..".bat" @@ -484,15 +484,56 @@ function MSRS:_ExectCommand(command) local script = io.open(filename, "w+") script:write(command.." && exit") script:close() - + -- Play command. - command=string.format('start /b "" "\"%s\"', filename) - - -- Play file in 0.05 seconds - timer.scheduleFunction(os.execute, command, timer.getTime()+0.01) + command=string.format('start /b "" "%s"', filename) + + if true then + + -- Create a tmp file. + local filenvbs = os.getenv('TMP') .. "\\MSRS-"..STTS.uuid()..".vbs" + + -- VBS script + local script = io.open(filenvbs, "w+") + script:write(string.format('Dim WinScriptHost\n')) + script:write(string.format('Set WinScriptHost = CreateObject("WScript.Shell")\n')) + script:write(string.format('WinScriptHost.Run Chr(34) & "%s" & Chr(34), 0\n', filename)) + script:write(string.format('Set WinScriptHost = Nothing')) + script:close() + + -- Run visual basic script. This still pops up a window but very briefly and does not put the DCS window out of focus. + local runvbs=string.format('cscript.exe //Nologo //B "%s"', filenvbs) + + -- Debug output. + self:I("MSRS execute command="..command) + self:I("MSRS execute VBS command="..runvbs) + + -- Now create powershell process and feed your script to its stdin + --local pipe = io.popen("cscript.exe //Nologo //B", "w") + --pipe:write(script) + --pipe:close() + + -- Play file in 0.01 seconds + os.execute(runvbs) + + -- Remove file in 1 second. + timer.scheduleFunction(os.remove, filename, timer.getTime()+1) + timer.scheduleFunction(os.remove, filenvbs, timer.getTime()+1) + + + else + + -- Debug output. + self:I("MSRS execute command="..command) + + -- Play file in 0.05 seconds + timer.scheduleFunction(os.execute, command, timer.getTime()+0.01) + + -- Remove file in 1 second. + timer.scheduleFunction(os.remove, filename, timer.getTime()+1) + + end - -- Remove file in 1 second. - timer.scheduleFunction(os.remove, filename, timer.getTime()+1) return res end @@ -535,6 +576,8 @@ function MSRS:_GetCommand(freqs, modus, coal, gender, voice, culture, volume, sp local command=string.format("start /min \"\" /d \"%s\" /b \"%s\" -f %s -m %s -c %s -p %s -n \"%s\" -h", path, exe, freqs, modus, coal, port, "ROBOT") --local command=string.format('start /b "" /d "%s" "%s" -f %s -m %s -c %s -p %s -n "%s" > bla.txt', path, exe, freqs, modus, coal, port, "ROBOT") + + local command=string.format('%s/%s -f %s -m %s -c %s -p %s -n "%s"', path, exe, freqs, modus, coal, port, "ROBOT") -- Set voice or gender/culture. if voice then