From 5f902517ffea8033605752f4755d81d4a9ba4aec Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Wed, 2 Mar 2016 13:48:55 +0100 Subject: [PATCH 1/1] using timer sharing; #114 --- helpers.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/helpers.lua b/helpers.lua index 5e958c3..137bd6a 100644 --- a/helpers.lua +++ b/helpers.lua @@ -77,8 +77,11 @@ end helpers.timer_table = {} -function helpers.newtimer(name, timeout, fun, nostart) - helpers.timer_table[name] = capi.timer({ timeout = timeout }) +function helpers.newtimer(_name, timeout, fun, nostart) + local name = timeout + if not helpers.timer_table[name] then + helpers.timer_table[name] = capi.timer({ timeout = timeout }) + end helpers.timer_table[name]:connect_signal("timeout", fun) helpers.timer_table[name]:start() if not nostart then -- 2.39.5