diff --git a/FS25_ADSmartPickup/adHitch.lua b/FS25_ADSmartPickup/adHitch.lua index 658f77c..275a38c 100644 --- a/FS25_ADSmartPickup/adHitch.lua +++ b/FS25_ADSmartPickup/adHitch.lua @@ -142,10 +142,19 @@ end local function vehicleState(adEnv, vehicle, markerId) local module = stateModule(vehicle) local wayPoint = adEnv.ADGraphManager:getWayPointById(markerId) + -- nærmeste led i sættet: bakker AD med vogn, er det vognen der ender på markøren, ikke traktoren + -- (in-game 28/9: vognen stod på Bredal, traktoren et vognslæb væk -> "stoppedAway") local distance = math.huge - if wayPoint ~= nil and vehicle.rootNode ~= nil then - local x, _, z = getWorldTranslation(vehicle.rootNode) - distance = math.sqrt((x - wayPoint.x) ^ 2 + (z - wayPoint.z) ^ 2) + local parts = {vehicle} + if vehicle.getChildVehicles ~= nil then + local ok, children = pcall(vehicle.getChildVehicles, vehicle) + if ok and children ~= nil then parts = children end + end + for _, part in pairs(parts) do + if wayPoint ~= nil and part.rootNode ~= nil then + local x, _, z = getWorldTranslation(part.rootNode) + distance = math.min(distance, math.sqrt((x - wayPoint.x) ^ 2 + (z - wayPoint.z) ^ 2)) + end end return { adActive = module ~= nil and module:isActive(), diff --git a/FS25_ADSmartPickup/modDesc.xml b/FS25_ADSmartPickup/modDesc.xml index 7c9be47..000a100 100644 --- a/FS25_ADSmartPickup/modDesc.xml +++ b/FS25_ADSmartPickup/modDesc.xml @@ -1,7 +1,7 @@ masterdraco - 1.47.3.0 + 1.47.4.0 <en>AD Smart Pickup</en>