printDebugMethodCalls
Definition
-- @/lua/vehicle/controller.lua:803
local function printDebugMethodCalls(callType)
local disclaimer = "\r\n\r\nCopy the contents of the method(s) below into their respective analogs in controller.lua and make sure the methods are not commented.\r\ncontroller.lua will automatically execute these hardcoded versions rather than using its internal loops\r\n \r\n "
print(disclaimer)
if callType == "update" or callType == nil then
print("local function updateFixedStepDebug(dt)")
print(" --Controllers not in this list do not have a matching method to call")
for i, controller in ipairs(sortedControllers) do
if controller.updateFixedStep ~= nil then
print(" sortedControllers[" .. i .. "].updateFixedStep(dt) -- " .. tostring(controller.typeName))
end
end
print("end")
print(" ")
print("local function updateDebug(dt)")
print(" --Controllers not in this list do not have a matching method to call")
for i, controller in ipairs(sortedControllers) do
if controller.update ~= nil then
print(" sortedControllers[" .. i .. "].update(dt) -- " .. controller.typeName)
end
end
print(" ")
print(" fixedStepTimer = fixedStepTimer + dt")
print(" if fixedStepTimer >= fixedStepTime then")
print(" updateFixedStepDebug(fixedStepTimer)")
print(" fixedStepTimer = fixedStepTimer - fixedStepTime")
print(" end")
print("end")
print(" ")
end
if callType == "updateGFX" or callType == nil then
print("local function updateGFXDebug(dt)")
print(" --Controllers not in this list do not have a matching method to call")
for i, controller in ipairs(sortedControllers) do
if controller.updateGFX ~= nil then
print(" sortedControllers[" .. i .. "].updateGFX(dt) -- " .. tostring(controller.typeName))
end
end
print("end")
print(" ")
end
if callType == "updateWheelsIntermediate" or callType == nil then
print("local function updateWheelsIntermediateDebug(dt)")
print(" --Controllers not in this list do not have a matching method to call")
for i, controller in ipairs(sortedControllers) do
if controller.updateWheelsIntermediate ~= nil then
print(" sortedControllers[" .. i .. "].updateWheelsIntermediate(dt) -- " .. tostring(controller.typeName))
end
end
print("end")
print(" ")
end
if callType == "beamBroke" or callType == nil then
print("local function beamBrokeDebug(id, energy)")
print(" --Controllers not in this list do not have a matching method to call")
for i, controller in ipairs(sortedControllers) do
if controller.beamBroke ~= nil then
print(" sortedControllers[" .. i .. "].beamBroke(id, energy) -- " .. tostring(controller.typeName))
end
end
print("end")
print(" ")
end
if callType == "beamDeformed" or callType == nil then
print("local function beamDeformedDebug(id, ratio)")
print(" --Controllers not in this list do not have a matching method to call")
for i, controller in ipairs(sortedControllers) do
if controller.beamDeformed ~= nil then
print(" sortedControllers[" .. i .. "].beamDeformed(id, ratio) -- " .. tostring(controller.typeName))
end
end
print("end")
print(" ")
end
if callType == "nodeCollision" or callType == nil then
print("local function nodeCollisionDebug(p)")
print(" --Controllers not in this list do not have a matching method to call")
for i, controller in ipairs(sortedControllers) do
if controller.nodeCollision ~= nil then
print(" sortedControllers[" .. i .. "].nodeCollision(p) -- " .. tostring(controller.typeName))
end
end
print("end")
print(" ")
end
if callType == "onCouplerFound" or callType == nil then
print("local function onCouplerFoundDebug(nodeId, obj2id, obj2nodeId)")
print(" --Controllers not in this list do not have a matching method to call")
for i, controller in ipairs(sortedControllers) do
if controller.onCouplerFound ~= nil then
print(" sortedControllers[" .. i .. "].onCouplerFound(nodeId, obj2id, obj2nodeId) -- " .. tostring(controller.typeName))
end
end
print("end")
print(" ")
end
if callType == "onCouplerAttached" or callType == nil then
print("local function onCouplerAttachedDebug(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)")
print(" --Controllers not in this list do not have a matching method to call")
for i, controller in ipairs(sortedControllers) do
if controller.onCouplerAttached ~= nil then
print(" sortedControllers[" .. i .. "].onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy) -- " .. tostring(controller.typeName))
end
end
print("end")
print(" ")
end
if callType == "onCouplerDetached" or callType == nil then
print("local function onCouplerDetachedDebug(nodeId, obj2id, obj2nodeId, breakForce)")
print(" --Controllers not in this list do not have a matching method to call")
for i, controller in ipairs(sortedControllers) do
if controller.onCouplerDetached ~= nil then
print(" sortedControllers[" .. i .. "].onCouplerDetached(nodeId, obj2id, obj2nodeId, breakForce) -- " .. tostring(controller.typeName))
end
end
print("end")
print(" ")
end
if callType == "onGameplayEvent" or callType == nil then
print("local function onGameplayEventDebug(eventName, ...)")
print(" --Controllers not in this list do not have a matching method to call")
for i, controller in ipairs(sortedControllers) do
if controller.onGameplayEvent ~= nil then
print(" sortedControllers[" .. i .. "].onGameplayEvent(eventName, ...) -- " .. tostring(controller.typeName))
end
end
print("end")
print(" ")
end
if callType == "debugDraw" or callType == nil then
print("local function debugDrawDebug(focusPos)")
print(" --Controllers not in this list do not have a matching method to call")
for i, controller in ipairs(sortedControllers) do
if controller.debugDraw ~= nil then
print(" sortedControllers[" .. i .. "].debugDraw(focusPos) -- " .. tostring(controller.typeName))
end
end
print("end")
print(" ")
end
if callType == "settingsChanged" or callType == nil then
print("local function settingsChangedDebug()")
print(" --Controllers not in this list do not have a matching method to call")
for i, controller in ipairs(sortedControllers) do
if controller.settingsChanged ~= nil then
print(" sortedControllers[" .. i .. "].settingsChanged() -- " .. tostring(controller.typeName))
end
end
print("end")
print(" ")
end
end
Callers
@/lua/vehicle/controller.lua
--These debug methods are here to be used in conjunction with controller.printDebugMethodCalls() to generate a hardcoded list of controller updates.
--Check the comments in updateFunctionCounts() for more info
--check if a hardcoded debug version of various methods exists, if so, execute that instead of the normal loop based version
--attention: these hardcoded methods are normally commented and need to be generated from a given vehicle via: "controller.printDebugMethodCalls()"
--copy the contents of that print into the relevant methods at the top of this file. Make sure (!!!) to remove it again when done