Skip to content

Commit 037f5cf

Browse files
author
Peter Vaiko
committed
fix: Pipe offset detection
Detect pipe offset also when the auger wagon with the pipe is not directly attached to the tractor, such in case of the Annaburger AW 22.16, which is attached through the HTS 22B.79 platform. #931
1 parent 6e4b6c7 commit 037f5cf

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

scripts/specializations/CpVehicleSettings.lua

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,17 @@ end
431431
--- If the vehicle has a pipe, instantiate a pipe controller to measure the pipe offsets. This is better
432432
--- done here and not when the vehicle starts as measuring is a hack and may mess up the vehicle states.
433433
function CpVehicleSettings:setPipeOffset()
434-
local pipeObject = AIUtil.getImplementOrVehicleWithSpecialization(self, Pipe)
435-
if self.isServer and pipeObject then
434+
local childVehiclesWithPipe, found = AIUtil.getAllChildVehiclesWithSpecialization(self, Pipe)
435+
if #childVehiclesWithPipe > 1 then
436+
CpUtil.infoVehicle(CpDebug.DBG_IMPLEMENTS, self, "More than one pipe found, using the first one")
437+
for _, vehicleWithPipe in ipairs(childVehiclesWithPipe) do
438+
CpUtil.infoVehicle(CpDebug.DBG_IMPLEMENTS, self, "\t vehicle with pipe: %s", CpUtil.getName(vehicleWithPipe))
439+
end
440+
end
441+
if self.isServer and childVehiclesWithPipe[1] ~= nil then
436442
local spec = self.spec_cpVehicleSettings
437443
-- ask the pipe controller to get the offsets
438-
local pipeController = PipeController(self, pipeObject, true)
444+
local pipeController = PipeController(self, childVehiclesWithPipe[1], true)
439445
spec.pipeOffsetX:setFloatValue(pipeController:getPipeOffsetX())
440446
spec.pipeOffsetZ:setFloatValue(pipeController:getPipeOffsetZ())
441447
CpUtil.debugVehicle(CpDebug.DBG_IMPLEMENTS, self, 'Pipe offsetX: %.1f, offsetZ: %.1f',

0 commit comments

Comments
 (0)