Skip to content

Commit

Permalink
Fix for #1986
Browse files Browse the repository at this point in the history
  • Loading branch information
schwiti6190 committed Oct 9, 2022
1 parent 282efe3 commit a16242f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
11 changes: 10 additions & 1 deletion scripts/CpUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,16 @@ function CpUtil.infoVehicle(vehicle, ...)
...)
end


function CpUtil.infoImplement(implement, ...)
local updateLoopIndex = g_updateLoopIndex and g_updateLoopIndex or 0
local timestamp = getDate( ":%S")
CpUtil.try(
function (...)
local rootVehicle = implement.rootVehicle or implement
print(string.format('%s [info lp%d] %s(%s): %s', timestamp, updateLoopIndex, CpUtil.getName(rootVehicle), CpUtil.getName(implement), string.format( ... )))
end,
...)
end

--- Create a node at x, z, direction according to yRotation.
--- If rootNode is given, make that the parent node, otherwise the parent is the terrain root node
Expand Down
24 changes: 23 additions & 1 deletion scripts/ai/controllers/PipeController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ function PipeController:setupMoveablePipe()
for i, m in ipairs(self.cylinderedSpec.movingTools) do
-- Gets only the pipe moving tools.
if m.freezingPipeStates ~= nil and next(m.freezingPipeStates) ~= nil then
table.insert(self.validMovingTools, m)
--- Only control pipe elements, that are controlled with the rot speed for now.
if m.rotSpeed ~= nil then
table.insert(self.validMovingTools, m)
end
end
end
end
Expand Down Expand Up @@ -173,6 +176,9 @@ function PipeController:setupMoveablePipe()

self.tempBaseNode = CpUtil.createNode("tempBaseNode", 0, 0, 0)
self.tempDependedNode = CpUtil.createNode("tempDependedNode", 0, 0, 0)

self:debug("Number of moveable pipe elements found: %d", #self.validMovingTools)

end

function PipeController:updateMoveablePipe(dt)
Expand Down Expand Up @@ -311,4 +317,20 @@ end
function PipeController:delete()
CpUtil.destroyNode(self.tempBaseNode)
CpUtil.destroyNode(self.tempDependedNode)
end

function PipeController:printMoveablePipeDebug()
CpUtil.infoImplement(self.implement, "Num of moveable tools: %d", #self.validMovingTools)
CpUtil.infoImplement(self.implement, "Base moving tool")
self:printMovingToolDebug(self.baseMovingTool)
CpUtil.infoImplement(self.implement, "Base moving tool child")
self:printMovingToolDebug(self.baseMovingToolChild)
end

function PipeController:printMovingToolDebug(tool)
if tool == nil then
CpUtil.infoImplement(self.implement, "Tool not found.")
return
end
CpUtil.infoImplement(self.implement, "RotMin: %s, RotMax: %s, RotSpeed", tostring(tool.rotMin), tostring(tool.rotMax), tostring(tool.rotSpeed))
end

0 comments on commit a16242f

Please sign in to comment.