From 0b36c896bb1c0a2feea9fd79a7f8732cea7a6133 Mon Sep 17 00:00:00 2001 From: Stijn Wopereis Date: Fri, 10 Mar 2023 19:47:14 +0100 Subject: [PATCH] #157: Skip blocking of lights, brakes etc when we don't have support the hose type in question on the vehicle. --- src/utils/ManualAttachUtil.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/utils/ManualAttachUtil.lua b/src/utils/ManualAttachUtil.lua index bedecb4..61dbde5 100644 --- a/src/utils/ManualAttachUtil.lua +++ b/src/utils/ManualAttachUtil.lua @@ -136,14 +136,29 @@ function ManualAttachUtil.hasAttachedConnectionHoses(object, type) local inputJointDescIndex = object.spec_attachable.inputAttacherJointDescIndex local hoses = object:getConnectionHosesByInputAttacherJoint(inputJointDescIndex) + local hasTypeMatch = false for _, hose in ipairs(hoses) do - if hose ~= nil and object:getIsConnectionHoseUsed(hose) then - if type == nil or ManualAttachConnectionHoses.TYPES_TO_INTERNAL[type][hose.type:upper()] then + if hose ~= nil then + local isConnected = object:getIsConnectionHoseUsed(hose) + if type == nil and isConnected then return true end + + if type ~= nil then + hasTypeMatch = ManualAttachConnectionHoses.TYPES_TO_INTERNAL[type][(hose.type):upper()] + + if hasTypeMatch and isConnected then + return true + end + end end end + --We don't have a hose with the type in question + if type ~= nil and not hasTypeMatch then + return true + end + return false end