From 52a4798377ae72a8e295929d2bbf4c12cc118ba2 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Sun, 12 Nov 2023 05:58:45 +0100 Subject: [PATCH] Added debug print func --- media/lua/client/TOC/Debug.lua | 8 ++++++++ media/lua/client/TOC/Handlers/AmputationHandler.lua | 2 +- media/lua/client/TOC/Handlers/ItemsHandler.lua | 6 +++--- media/lua/client/TOC/Handlers/PlayerHandler.lua | 2 +- media/lua/client/TOC/Handlers/ProsthesisHandler.lua | 2 +- media/lua/client/TOC/UI/CutLimbInteractions.lua | 2 +- media/lua/shared/NPCs/TOC_BodyLocations.lua | 2 +- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/media/lua/client/TOC/Debug.lua b/media/lua/client/TOC/Debug.lua index dae82af..695ee6c 100644 --- a/media/lua/client/TOC/Debug.lua +++ b/media/lua/client/TOC/Debug.lua @@ -4,4 +4,12 @@ TOC_DEBUG.disablePaneMod = false function TOC_DEBUG.togglePaneMod() TOC_DEBUG.disablePaneMod = not TOC_DEBUG.disablePaneMod +end + +---comment +---@param string string +function TOC_DEBUG.print(string) + if isDebugEnabled() then + print("TOC: " .. string) + end end \ No newline at end of file diff --git a/media/lua/client/TOC/Handlers/AmputationHandler.lua b/media/lua/client/TOC/Handlers/AmputationHandler.lua index 2e995d0..2ba7c27 100644 --- a/media/lua/client/TOC/Handlers/AmputationHandler.lua +++ b/media/lua/client/TOC/Handlers/AmputationHandler.lua @@ -40,7 +40,7 @@ end ---Starts bleeding from the point where the saw is being used function AmputationHandler:damageDuringAmputation() - print("TOC: Damage patient") + TOC_DEBUG.print("damage patient") local bodyDamage = self.patient:getBodyDamage() local bodyDamagePart = bodyDamage:getBodyPart(self.bodyPartType) diff --git a/media/lua/client/TOC/Handlers/ItemsHandler.lua b/media/lua/client/TOC/Handlers/ItemsHandler.lua index e036763..f5e6f55 100644 --- a/media/lua/client/TOC/Handlers/ItemsHandler.lua +++ b/media/lua/client/TOC/Handlers/ItemsHandler.lua @@ -47,7 +47,7 @@ function ItemsHandler.RemoveClothingItem(playerObj, clothingItem) playerObj:removeWornItem(clothingItem) playerObj:getInventory():Remove(clothingItem) -- Can be a InventoryItem too.. I guess? todo check it - print("TOC: found and deleted " .. tostring(clothingItem)) + TOC_DEBUG.print("found and deleted" .. tostring(clothingItem)) return true end return false @@ -87,7 +87,7 @@ end ---Spawns and equips the correct amputation item to the player. function ItemsHandler.SpawnAmputationItem(playerObj, limbName) - print("Clothing name " .. StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName) + TOC_DEBUG.print("clothing name " .. StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName) local clothingItem = playerObj:getInventory():AddItem(StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName) local texId = ItemsHandler.GetAmputationTexturesIndex(playerObj, false) @@ -108,7 +108,7 @@ function ISInventoryPane:refreshContainer() for i=1, #self.itemslist do local cItem = self.itemslist[i] if cItem and cItem.cat == "Amputation" then - --print("TOC: current item is an amputation, removing it from the list") + TOC_DEBUG.print("current item is an amputation, removing it from the list") table.remove(self.itemslist, i) end end diff --git a/media/lua/client/TOC/Handlers/PlayerHandler.lua b/media/lua/client/TOC/Handlers/PlayerHandler.lua index a734cf4..cb2fed0 100644 --- a/media/lua/client/TOC/Handlers/PlayerHandler.lua +++ b/media/lua/client/TOC/Handlers/PlayerHandler.lua @@ -88,7 +88,7 @@ end ---Cache the currently amputated limbs ---@param limbName string function PlayerHandler.AddLocalAmputatedLimb(limbName) - print("TOC: added " .. limbName .. " to known amputated limbs") + TOC_DEBUG.print("added " .. limbName .. " to known amputated limbs") table.insert(PlayerHandler.amputatedLimbs, limbName) -- TODO This should be player specific, not generic end diff --git a/media/lua/client/TOC/Handlers/ProsthesisHandler.lua b/media/lua/client/TOC/Handlers/ProsthesisHandler.lua index 34af12d..f90d214 100644 --- a/media/lua/client/TOC/Handlers/ProsthesisHandler.lua +++ b/media/lua/client/TOC/Handlers/ProsthesisHandler.lua @@ -16,7 +16,7 @@ end ---@param bodyLocation string ---@return boolean function ProsthesisHandler.CheckIfEquippable(bodyLocation) - print("Current item is a prosthesis") + TOC_DEBUG.print("current item is a prosthesis") local side = CommonMethods.GetSide(bodyLocation) for i=1, #PlayerHandler.amputatedLimbs do diff --git a/media/lua/client/TOC/UI/CutLimbInteractions.lua b/media/lua/client/TOC/UI/CutLimbInteractions.lua index 9003e0e..2c6dab2 100644 --- a/media/lua/client/TOC/UI/CutLimbInteractions.lua +++ b/media/lua/client/TOC/UI/CutLimbInteractions.lua @@ -106,7 +106,7 @@ function CutLimbHandler:isValid(itemType) end function CutLimbHandler:perform(previousAction, itemType) - print("perform cutlimbhandler") + TOC_DEBUG.print("perform CutLimbHandler") local item = self:getItemOfType(self.items.ITEMS, itemType) previousAction = self:toPlayerInventory(item, previousAction) diff --git a/media/lua/shared/NPCs/TOC_BodyLocations.lua b/media/lua/shared/NPCs/TOC_BodyLocations.lua index 6f68bef..eed5c37 100644 --- a/media/lua/shared/NPCs/TOC_BodyLocations.lua +++ b/media/lua/shared/NPCs/TOC_BodyLocations.lua @@ -5,7 +5,7 @@ local function AddBodyLocationBefore(newLocation, moveToLocation) local list = getClassFieldVal(group, getClassField(group, 1)) group:getOrCreateLocation(newLocation) local newItem = list:get(list:size()-1) - print("TOC: Created new body location" .. newItem:getId()) + TOC_DEBUG.print("created new body location" .. newItem:getId()) list:remove(newItem) -- We can't use the Index, it works if we pass the item though! local i = group:indexOf(moveToLocation) list:add(i, newItem)