Skip to content

Commit 5edc7a4

Browse files
authored
Merge pull request #957 from Courseplay/931-annaburger-aw-2216-auger-wagon-tries-to-unload-on-wrong-side
fix: Pipe offset detection
2 parents 565c863 + 037f5cf commit 5edc7a4

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)