Added some protection against unexpectedly-nil values.

This commit is contained in:
Michael Barnes 2020-03-05 13:05:25 +10:00
parent 4ef827836c
commit 7cf73af707

View File

@ -316,10 +316,13 @@ function GROUP:GetPositionVec3() -- Overridden from POSITIONABLE:GetPositionVec3
local DCSPositionable = self:GetDCSObject() local DCSPositionable = self:GetDCSObject()
if DCSPositionable then if DCSPositionable then
local PositionablePosition = DCSPositionable:getUnits()[1]:getPosition().p local unit = DCSPositionable:getUnits()[1]
if unit then
local PositionablePosition = unit:getPosition().p
self:T3( PositionablePosition ) self:T3( PositionablePosition )
return PositionablePosition return PositionablePosition
end end
end
return nil return nil
end end
@ -366,10 +369,12 @@ function GROUP:IsActive()
local DCSGroup = self:GetDCSObject() -- DCS#Group local DCSGroup = self:GetDCSObject() -- DCS#Group
if DCSGroup then if DCSGroup then
local unit = DCSGroup:getUnit(1)
local GroupIsActive = DCSGroup:getUnit(1):isActive() if unit then
local GroupIsActive = unit:isActive()
return GroupIsActive return GroupIsActive
end end
end
return nil return nil
end end