Skip to content

Commit

Permalink
Hotfix for no best time on record
Browse files Browse the repository at this point in the history
Implementation in v1.1 would conk out if no previous time was recorded
(comparing numbers to nil). Added a catch for that.
  • Loading branch information
MaeBee committed May 5, 2017
1 parent 690f4b5 commit 2f93e45
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.zip
19 changes: 12 additions & 7 deletions WereWatch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,19 @@ function WereWatch.OnWerewolfStateChanged(eventCode, werewolf)
-- calculate time difference
WereWatch.deltaTime = GetDiffBetweenTimeStamps(WereWatch.stopTime, WereWatch.startTime)
-- check for best time
if WereWatch.deltaTime > WereWatch.savedVariables.bestTime then
-- New best time!
d("[WereWatch] You held your werewolf form for ".. WereWatch.ToMinSec(WereWatch.deltaTime) .. ". This beats your previous best time of " .. WereWatch.ToMinSec(WereWatch.savedVariables.bestTime) .. "!")
if WereWatch.savedVariables.bestTime ~= nil then
if WereWatch.deltaTime > WereWatch.savedVariables.bestTime then
-- New best time!
d("[WereWatch] You held your werewolf form for ".. WereWatch.ToMinSec(WereWatch.deltaTime) .. ". This beats your previous best time of " .. WereWatch.ToMinSec(WereWatch.savedVariables.bestTime) .. "!")
WereWatch.savedVariables.bestTime = WereWatch.deltaTime
elseif WereWatch.deltaTime < WereWatch.savedVariables.bestTime then
-- No new best time.
d("[WereWatch] You held your werewolf form for " .. WereWatch.ToMinSec(WereWatch.deltaTime) .. ". Your best time is " .. WereWatch.ToMinSec(WereWatch.savedVariables.bestTime) .. ".")
end -- if WereWatch.deltaTime
else
d("[WereWatch] You held your werewolf form for ".. WereWatch.ToMinSec(WereWatch.deltaTime) .. ". No previous best time found.")
WereWatch.savedVariables.bestTime = WereWatch.deltaTime
elseif WereWatch.deltaTime < WereWatch.savedVariables.bestTime then
-- No new best time.
d("[WereWatch] You held your werewolf form for " .. WereWatch.ToMinSec(WereWatch.deltaTime) .. ". Your best time is " .. WereWatch.ToMinSec(WereWatch.savedVariables.bestTime) .. ".")
end -- if WereWatch.deltaTime
end -- if WereWatch.savedVariables.bestTime
end -- if werewolf
end -- if werewolf ~= WereWatch.werewolf
end -- function
Expand Down

0 comments on commit 2f93e45

Please sign in to comment.