mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Add checks and trace for RADIO:New
This commit is contained in:
parent
f35269936f
commit
a9c7cd4e18
@ -30,19 +30,22 @@ RADIO = {
|
|||||||
Loop = 0,
|
Loop = 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- @TODO Manage Trace in all functions below
|
--- Create a new RADIO Object. This doesn't broadcast a transmission, though, use @{#RADIO.Broadcast} to actually broadcast
|
||||||
|
-- @param Wrapper.Positionable#POSITIONABLE Positionable
|
||||||
--- Create a new RADIO Object. This doesn't broadcast a transmission, though, use @{Radio#RADIO.Broadcast} to actually broadcast
|
-- @return #RADIO Radio
|
||||||
-- @param #POSITIONABLE Positionable
|
-- @return #nil If Positionable is invalid
|
||||||
-- @return self
|
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- If you want to create a RADIO, you probably should use @{Positionable#POSITIONABLE.GetRadio}
|
-- -- If you want to create a RADIO, you probably should use @{Wrapper.Positionable#POSITIONABLE.GetRadio} instead
|
||||||
function RADIO:New(positionable)
|
function RADIO:New(positionable)
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, BASE:New() )
|
||||||
self:F(positionable)
|
self:F(positionable)
|
||||||
|
if positionable:GetPointVec2() ~= nil then -- It's stupid, but the only way I found to make sure positionable is valid
|
||||||
self.Positionable = positionable
|
self.Positionable = positionable
|
||||||
return self
|
return self
|
||||||
|
else
|
||||||
|
self:E({"The passed positionable is invalid, no RADIO created : ", positionable})
|
||||||
|
return nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add the 'l10n/DEFAULT/' in the file name if necessary
|
--- Add the 'l10n/DEFAULT/' in the file name if necessary
|
||||||
@ -51,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:_VerifyFileName(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,7 +75,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:NewGenericTransmission(...)
|
function RADIO:NewGenericTransmission(...)
|
||||||
self:F2(arg)
|
self:F2(arg)
|
||||||
self.FileName = RADIO:VerifyFileName(arg[1])
|
self.FileName = RADIO:_VerifyFileName(arg[1])
|
||||||
if arg[2] ~= nil then
|
if arg[2] ~= nil then
|
||||||
self.Frequency = arg[2] * 1000 -- Convert to Hz
|
self.Frequency = arg[2] * 1000 -- Convert to Hz
|
||||||
end
|
end
|
||||||
@ -102,7 +105,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:_VerifyFileName(arg[1])
|
||||||
if arg[2] ~= nil then
|
if arg[2] ~= nil then
|
||||||
self.Subtitle = arg[2]
|
self.Subtitle = arg[2]
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
BASE:TraceAll(1)
|
BASE:TraceOnOff(true)
|
||||||
BASE:TraceLevel(1)
|
BASE:TraceClass("RADIO")
|
||||||
|
BASE:TraceLevel(3)
|
||||||
|
|
||||||
|
|
||||||
local Player = UNIT:FindByName("Player")
|
local Player = UNIT:FindByName("Player")
|
||||||
Player:MessageToAll("MainScript Started 2", 10, "")
|
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("Test Voice.ogg", 251000, radio.modulation.AM, 1000)
|
StaticRadio:NewGenericTransmission("Noise.ogg", 251000, radio.modulation.AM, 1000)
|
||||||
StaticRadio:Broadcast()
|
StaticRadio:Broadcast()
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user