From 7cf73af7079d17e4fd1a4f0eeefe1c14b084bfee Mon Sep 17 00:00:00 2001 From: Michael Barnes Date: Thu, 5 Mar 2020 13:05:25 +1000 Subject: [PATCH] Added some protection against unexpectedly-nil values. --- Moose Development/Moose/Wrapper/Group.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 3fc5e672a..484dc160b 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -316,9 +316,12 @@ function GROUP:GetPositionVec3() -- Overridden from POSITIONABLE:GetPositionVec3 local DCSPositionable = self:GetDCSObject() 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 ) return PositionablePosition + end end return nil @@ -366,9 +369,11 @@ function GROUP:IsActive() local DCSGroup = self:GetDCSObject() -- DCS#Group if DCSGroup then - - local GroupIsActive = DCSGroup:getUnit(1):isActive() + local unit = DCSGroup:getUnit(1) + if unit then + local GroupIsActive = unit:isActive() return GroupIsActive + end end return nil