Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions scripts/specializations/CpVehicleSettings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,17 @@ end
--- If the vehicle has a pipe, instantiate a pipe controller to measure the pipe offsets. This is better
--- done here and not when the vehicle starts as measuring is a hack and may mess up the vehicle states.
function CpVehicleSettings:setPipeOffset()
local pipeObject = AIUtil.getImplementOrVehicleWithSpecialization(self, Pipe)
if self.isServer and pipeObject then
local childVehiclesWithPipe, found = AIUtil.getAllChildVehiclesWithSpecialization(self, Pipe)
if #childVehiclesWithPipe > 1 then
CpUtil.infoVehicle(CpDebug.DBG_IMPLEMENTS, self, "More than one pipe found, using the first one")
for _, vehicleWithPipe in ipairs(childVehiclesWithPipe) do
CpUtil.infoVehicle(CpDebug.DBG_IMPLEMENTS, self, "\t vehicle with pipe: %s", CpUtil.getName(vehicleWithPipe))
end
end
if self.isServer and childVehiclesWithPipe[1] ~= nil then
local spec = self.spec_cpVehicleSettings
-- ask the pipe controller to get the offsets
local pipeController = PipeController(self, pipeObject, true)
local pipeController = PipeController(self, childVehiclesWithPipe[1], true)
spec.pipeOffsetX:setFloatValue(pipeController:getPipeOffsetX())
spec.pipeOffsetZ:setFloatValue(pipeController:getPipeOffsetZ())
CpUtil.debugVehicle(CpDebug.DBG_IMPLEMENTS, self, 'Pipe offsetX: %.1f, offsetZ: %.1f',
Expand Down
Loading