From 89c12b4a0b56cff64d5281ebac83af7489ea0806 Mon Sep 17 00:00:00 2001 From: bizcochito Date: Mon, 7 Feb 2022 09:36:16 +0100 Subject: [PATCH] Changed loggin to only log when enabled with logPrint function --- data/scripts/debug.lua | 4 ++++ data/scripts/level.lua | 6 +++--- data/scripts/ui/dialog.lua | 2 +- main.lua | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/data/scripts/debug.lua b/data/scripts/debug.lua index da05bc3..51689cb 100644 --- a/data/scripts/debug.lua +++ b/data/scripts/debug.lua @@ -87,3 +87,7 @@ function checkCPUTime(action, name) end end end]] + +function logPrint(string) + if logging then print(string) end +end diff --git a/data/scripts/level.lua b/data/scripts/level.lua index a6d19c1..d924e66 100644 --- a/data/scripts/level.lua +++ b/data/scripts/level.lua @@ -245,7 +245,7 @@ function GridDisplay() end function TileOptimizeObjects() - print("new optimization") + logPrint("new optimization") local unoptimized = 0 local isTileOptimized = {} @@ -280,7 +280,7 @@ function TileOptimizeObjects() end end - print(n) + logPrint("Group size: "..n) unoptimized = unoptimized + n local base_x = tileProperties.scale * j * tileProperties.width + tileProperties.scale * (levelProperties.offset.x - tileProperties.height) local base_y = tileProperties.scale * i * tileProperties.height + tileProperties.scale * (levelProperties.offset.y - tileProperties.height) @@ -297,7 +297,7 @@ function TileOptimizeObjects() end end - print("collisions optimized from " .. unoptimized .. " to " .. #LoadedObjects.Collisions) + logPrint("collisions optimized from " .. unoptimized .. " to " .. #LoadedObjects.Collisions) end function TileCreateObjects() diff --git a/data/scripts/ui/dialog.lua b/data/scripts/ui/dialog.lua index 5bbb1d5..91d2afa 100644 --- a/data/scripts/ui/dialog.lua +++ b/data/scripts/ui/dialog.lua @@ -59,7 +59,7 @@ function interfaceDialog:checkConfirm() if love.mouse.isDown(1) then self.clicked = true self.value = self.value + 1 - print(self.value.." of "..self.target_value) + logPrint(self.value.." of "..self.target_value) self:updateContents() end elseif not love.mouse.isDown(1) then diff --git a/main.lua b/main.lua index 39e0e4d..4ce65ed 100644 --- a/main.lua +++ b/main.lua @@ -57,7 +57,7 @@ function love.load() gravity = 0.2 -- Debug and log stuff memoryUsage, dtcount = 0, 0 - if logging then print("mothback: "..collectgarbage("count").." kB, Loading time: "..os.clock().." seconds") end + logPrint("mothback: "..collectgarbage("count").." kB, Loading time: "..os.clock().." seconds") end function love.update(dt) @@ -81,7 +81,7 @@ function love.update(dt) if debug or logging then memoryUsage = math.floor(collectgarbage("count")) end - if logging then print("Second "..secs..": "..memoryUsage.." kB") end + logPrint("Second "..secs..": "..memoryUsage.." kB") end --keypressed