mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Add checks and trace for RADIO:NewGenericTransmission
This commit is contained in:
parent
a9c7cd4e18
commit
e4343179b3
@ -43,7 +43,7 @@ function RADIO:New(positionable)
|
|||||||
self.Positionable = positionable
|
self.Positionable = positionable
|
||||||
return self
|
return self
|
||||||
else
|
else
|
||||||
self:E({"The passed positionable is invalid, no RADIO created : ", positionable})
|
self:E({"The passed positionable is invalid, no RADIO created", positionable})
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -54,7 +54,7 @@ end
|
|||||||
-- @return #string FileName Corrected file name
|
-- @return #string FileName Corrected file name
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- internal use only
|
-- -- internal use only
|
||||||
function RADIO:_VerifyFileName(filename)
|
function RADIO:_CorrectFileName(filename)
|
||||||
if filename:find("l10n/DEFAULT/") == nil then
|
if filename:find("l10n/DEFAULT/") == nil then
|
||||||
filename = "l10n/DEFAULT/" .. filename
|
filename = "l10n/DEFAULT/" .. filename
|
||||||
end
|
end
|
||||||
@ -72,22 +72,40 @@ end
|
|||||||
-- -- In this function the data is especially relevant if the broadcaster is anything but a UNIT or a GROUP,
|
-- -- In this function the data is especially relevant if the broadcaster is anything but a UNIT or a GROUP,
|
||||||
-- -- but it will work with a UNIT or a GROUP anyway
|
-- -- but it will work with a UNIT or a GROUP anyway
|
||||||
-- -- Only the RADIO and the Filename are mandatory
|
-- -- Only the RADIO and the Filename are mandatory
|
||||||
-- @TODO : Verify the type of passed args and throw errors when necessary
|
--TODO : Verify the type of passed args and throw errors when necessary
|
||||||
function RADIO:NewGenericTransmission(...)
|
function RADIO:NewGenericTransmission(...)
|
||||||
self:F2(arg)
|
self:F2(arg)
|
||||||
self.FileName = RADIO:_VerifyFileName(arg[1])
|
-- Check if the file has an extension
|
||||||
|
if arg[1]:find(".ogg") ~= nil or arg[1]:find(".wav") ~= nil then
|
||||||
|
self.FileName = RADIO:_CorrectFileName(arg[1])
|
||||||
|
else
|
||||||
|
self:E("File name invalid. Check the extension (Parameter [1] ignored, transmission not created)")
|
||||||
|
end
|
||||||
|
|
||||||
if arg[2] ~= nil then
|
if arg[2] ~= nil then
|
||||||
|
-- Check if the frequency is in range allowed by DCS
|
||||||
|
if (arg[2] >= 30 and arg[2] < 88) or (arg[2] >= 108 and arg[2] < 152) or (arg[2] >= 225 and arg[2] < 400) then
|
||||||
self.Frequency = arg[2] * 1000 -- Convert to Hz
|
self.Frequency = arg[2] * 1000 -- Convert to Hz
|
||||||
|
else
|
||||||
|
self:E("Frequency is outside of DCS Frequency ranges (30-80, 108-152, 225-400) (Parameter [2] ignored)")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if arg[3] ~= nil then
|
if arg[3] ~= nil then
|
||||||
|
if arg[3] == radio.modulation.AM or arg[3] == radio.modulation.FM then
|
||||||
self.Modulation = arg[3]
|
self.Modulation = arg[3]
|
||||||
|
else
|
||||||
|
self:E("Modulation is invalid. Use DCS's enum radio.modulation (Parameter [3] ignored)")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if arg[4] ~= nil then
|
if arg[4] ~= nil then
|
||||||
self.Power = arg[4]
|
self.Power = math.floor(math.abs(arg[4]))
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Create a new transmission, that is to say, populate the RADIO with relevant data
|
--- Create a new transmission, that is to say, populate the RADIO with relevant data
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #string Filename
|
-- @param #string Filename
|
||||||
@ -105,7 +123,7 @@ end
|
|||||||
-- -- @TODO : Verify the type of passed args and throw errors when necessary
|
-- -- @TODO : Verify the type of passed args and throw errors when necessary
|
||||||
function RADIO:NewUnitTransmission(...)
|
function RADIO:NewUnitTransmission(...)
|
||||||
self:F2(arg)
|
self:F2(arg)
|
||||||
self.FileName = RADIO:_VerifyFileName(arg[1])
|
self.FileName = RADIO:_CorrectFileName(arg[1])
|
||||||
if arg[2] ~= nil then
|
if arg[2] ~= nil then
|
||||||
self.Subtitle = arg[2]
|
self.Subtitle = arg[2]
|
||||||
end
|
end
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -9,5 +9,5 @@ Player:MessageToAll("MainScript Started 2", 10, "")
|
|||||||
local Static = STATIC:FindByName("CommandCenter")
|
local Static = STATIC:FindByName("CommandCenter")
|
||||||
|
|
||||||
local StaticRadio = Static:GetRadio()
|
local StaticRadio = Static:GetRadio()
|
||||||
StaticRadio:NewGenericTransmission("Noise.ogg", 251000, radio.modulation.AM, 1000)
|
StaticRadio:NewGenericTransmission("Noise", 251000, radio.modulation.AM, 1000)
|
||||||
StaticRadio:Broadcast()
|
StaticRadio:Broadcast()
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user