From 6ae7a555bfd0dde6967d716b4439f1c47911b5d4 Mon Sep 17 00:00:00 2001 From: Julian Date: Sun, 15 May 2016 02:57:44 +0900 Subject: lua: add timer:is_enabled() function Allows to query if some timer is currently running or was stopped/killed. --- DOCS/man/lua.rst | 4 ++++ player/lua/defaults.lua | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/DOCS/man/lua.rst b/DOCS/man/lua.rst index 35124a788f..b0d66c1760 100644 --- a/DOCS/man/lua.rst +++ b/DOCS/man/lua.rst @@ -350,6 +350,10 @@ The ``mp`` module is preloaded, although it can be loaded manually with with ``add_timeout()``), this starts the timer from the beginning, using the initially configured timeout. + ``is_enabled()`` + Whether the timer is currently enabled or was previously disabled + (e.g. by ``stop()`` or ``kill()``). + ``timeout`` (RW) This field contains the current timeout period. This value is not updated as time progresses. It's only used to calculate when the diff --git a/player/lua/defaults.lua b/player/lua/defaults.lua index a12e5bd3c3..e499ecc917 100644 --- a/player/lua/defaults.lua +++ b/player/lua/defaults.lua @@ -275,6 +275,10 @@ function timer_mt.resume(t) end end +function timer_mt.is_enabled(t) + return timers[t] ~= nil +end + -- Return the timer that expires next. local function get_next_timer() local best = nil -- cgit v1.2.3