RADIO:SetFileName() and RADIO:SetFrequency() both tested and fixed

This commit is contained in:
Grey-Echo 2017-03-10 23:34:32 +01:00
parent 4655a6413d
commit 894ed41374
5 changed files with 53 additions and 67232 deletions

View File

@ -59,9 +59,9 @@ function RADIO:SetFileName(filename)
if filename:find(".ogg") ~= nil or filename:find(".wav") ~= nil then
if filename:find("l10n/DEFAULT/") == nil then
filename = "l10n/DEFAULT/" .. filename
self.FileName = filename
return self
end
self.FileName = filename
return self
end
end
self:E({"File name invalid. Maybe something wrong with the extension ?", self.FileName})
@ -70,7 +70,7 @@ end
--- Check validity of the frequency passed and sets RADIO.Frequency
-- @param #RADIO self
-- @param #number frequency
-- @param #number frequency in MHz
-- @return self
-- @usage
function RADIO:SetFrequency(frequency)
@ -78,7 +78,7 @@ function RADIO:SetFrequency(frequency)
if type(frequency) == "number" then
-- If frequency is in range
if (frequency >= 30 and frequency < 88) or (frequency >= 108 and frequency < 152) or (frequency >= 225 and frequency < 400) then
self.Frequency = frequency * 1000 -- Coversion in Hz
self.Frequency = frequency * 1000000 -- Coversion in Hz
-- If the RADIO is attached to a UNIT or a GROUP, we need to send the DCS Command "SetFrequency" to change the UNIT or GROUP frequency
if self.Positionable.ClassName == "UNIT" or self.Positionable.ClassName == "GROUP" then
self.Positionable:GetDCSObject():getController():setCommand({
@ -222,6 +222,7 @@ function RADIO:Broadcast()
self:F()
-- If the POSITIONABLE is actually a Unit or a Group, use the more complicated DCS function
if self.Positionable.ClassName == "UNIT" or self.Positionable.ClassName == "GROUP" then
self:T2("Broadcasting from a UNIT or a GROUP")
self.Positionable:GetDCSObject():getController():setCommand({
id = "TransmitMessage",
params = {
@ -233,6 +234,7 @@ function RADIO:Broadcast()
})
else
-- If the POSITIONABLE is anything else, we revert to the general function
self:T2("Broadcasting from a POSITIONABLE")
trigger.action.radioTransmission(self.FileName, self.Positionable:GetPositionVec3(), self.Modulation, false, self.Frequency, self.Power)
end
return self

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,10 +4,19 @@ BASE:TraceLevel(3)
local Player = UNIT:FindByName("Player")
Player:MessageToAll("MainScript Started 2", 10, "")
Player:MessageToAll("MainScript Started 3", 10, "")
local Static = STATIC:FindByName("CommandCenter")
local Transmiter = UNIT:FindByName("Transmiter")
local StaticRadio = Static:GetRadio()
StaticRadio:NewGenericTransmission("Noise", 251000, radio.modulation.AM, 1000)
StaticRadio:Broadcast()
local Radio = Transmiter:GetRadio()
Radio:SetFrequency(25)
Radio:SetFrequency(89)
Radio:SetFrequency(152)
Radio:SetFrequency(500)
Radio:SetFrequency("a")
Radio:SetFrequency(225)
Radio:SetFrequency(251.3)
Radio:SetFileName("Noise.ogg")
Radio:Broadcast()