Skip to content

Commit

Permalink
fixed AutoQuit widget. It will now autoquit 15 seconds. Moving mouse …
Browse files Browse the repository at this point in the history
…resets the timer
  • Loading branch information
Damgam committed Jan 9, 2019
1 parent 8ef98e1 commit 140dcbf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions LuaUI/Widgets_Evo/cmd_autoquit.lua
Expand Up @@ -3,7 +3,7 @@
-- global variables
----------------------------------------------------------------
local versionNumber = "v1.2"
local delay = 8
local delay = 15
local endTime
local mx,my

Expand All @@ -23,7 +23,7 @@ local GetMouseState = Spring.GetMouseState
function widget:GetInfo()
return {
name = "Autoquit",
desc = versionNumber .. " Automatically quits "..delay.."s after the game ends. Move mouse to postpone. (each minute) ",
desc = versionNumber .. " Automatically quits "..delay.."s after the game ends. Move mouse to postpone.",
author = "Evil4Zerggin & zwzsg",
date = "25 December 2008",
license = "GNU LGPL, v2.1 or later",
Expand All @@ -39,16 +39,18 @@ end
function widget:GameOver()
endTime = GetTimer()
mx,my = GetMouseState()
Echo("<autoquit> Automatically exiting in " .. delay .. " seconds. Move mouse to cancel.")
Echo("<autoquit> Automatically exiting in " .. delay .. " seconds since last mouse movement")
end

function widget:Update(dt)
CurrTimer = DiffTimers(GetTimer(), endTime)
if endTime then
local nmx,nmy = GetMouseState()
if nmx~=mx or nmy~=my then
--Echo("<autoquit> Autoquit canceled.")
--endTime = false
endTime = GetTimer() + 60 -- set new endtime, because I've had times that game was running for ages because i wasnt attending pc but somehow it detect a move
Echo(GetTimer())
endTime = GetTimer() -- set new endtime, because I've had times that game was running for ages because i wasnt attending pc but somehow it detect a move
mx,my = GetMouseState()
-- widgetHandler:RemoveWidget(self)
elseif DiffTimers(GetTimer(), endTime) > delay then
Expand Down

0 comments on commit 140dcbf

Please sign in to comment.