From a80644401f06838154c7534464d442becea5c4d6 Mon Sep 17 00:00:00 2001 From: Matthew Ellison Date: Mon, 11 Mar 2019 18:46:20 -0400 Subject: [PATCH] Fixed bug that was giving an error in time --- Stopwatch.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Stopwatch.lua b/Stopwatch.lua index 957c5a5..01a226a 100644 --- a/Stopwatch.lua +++ b/Stopwatch.lua @@ -49,11 +49,11 @@ end function Stopwatch:getTime() local timeDifference = nil; --If start and stop has been called return the difference - if(startTime and stopTime) then - timeDifference = endTime - startTime; + if((self.startTime ~= nil) and (self.stopTime ~= nil)) then + timeDifference = self.stopTime - self.startTime; --If start has been called but stop hasn't make the current time the end time. This simulates looking at a stopwatch while it is still running - elseif(startTime and not stopTime) then - timeDifference = os.time() - startTime; + elseif((self.startTime ~= nil) and (self.stopTime == nil)) then + timeDifference = os.time() - self.startTime; --Otherwise return -1 as an error else timeDifference = -1;