Permalink
Browse files

fixed AutoQuit widget. It will now autoquit 15 seconds. Moving mouse …

…resets the timer
  • Loading branch information...
Damgam committed Jan 9, 2019
1 parent 8ef98e1 commit 140dcbf5cad4b8689e5736ffc91997f58530a146
Showing with 6 additions and 4 deletions.
  1. +6 −4 LuaUI/Widgets_Evo/cmd_autoquit.lua
@@ -3,7 +3,7 @@
-- global variables
----------------------------------------------------------------
local versionNumber = "v1.2"
local delay = 8
local delay = 15
local endTime
local mx,my

@@ -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",
@@ -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

0 comments on commit 140dcbf

Please sign in to comment.