Fixed bug that was giving an error in time

This commit is contained in:
2019-03-11 18:46:20 -04:00
parent 88cf1b96d6
commit a80644401f

View File

@@ -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;