@@ -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.
433433function 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