diff --git a/lua/entities/gmod_wire_expression2/core/bone.lua b/lua/entities/gmod_wire_expression2/core/bone.lua index 00522e120f..2ca6af720b 100644 --- a/lua/entities/gmod_wire_expression2/core/bone.lua +++ b/lua/entities/gmod_wire_expression2/core/bone.lua @@ -19,7 +19,6 @@ end) -- faster access to some math library functions local abs = math.abs local atan2 = math.atan2 -local sqrt = math.sqrt local asin = math.asin local Clamp = math.Clamp @@ -47,15 +46,19 @@ local function GetBones(entity) end E2Lib.GetBones = GetBones --- checks whether the bone is valid. if yes, returns the bone's entity; otherwise, returns nil. -local function isValidBone(b) - if type(b) ~= "PhysObj" or not IsValid(b) then return nil, 0 end - local ent = b:GetEntity() +-- checks whether the bone is valid. if yes, returns the bone's entity and bone's index; otherwise, returns nil and 0. +local function isValidBone(bone) + if type(bone) ~= "PhysObj" or not bone:IsValid() then return nil, 0 end + + local ent = bone:GetEntity() + if not ent:IsValid() then - return nil + return nil, 0 end - return ent + + return ent, bone:GetIndex() end + E2Lib.isValidBone = isValidBone --[[************************************************************************]]--