Skip to content

Commit

Permalink
Merge pull request #11 from hbomb79/patch-1
Browse files Browse the repository at this point in the history
Re-use code in timer.lua (src/lib)
  • Loading branch information
exerro committed Dec 10, 2015
2 parents 1a8afa3 + d79b826 commit 6df9de4
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/lib/timer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ end
function timer.queue( n, response )
parameters.check( 2, "n", "number", n, "response", "function", response )

local finish, ID = t + n, false -- avoids duplicating timer events
for i = 1, #timers do
if timers[i].time == finish then
ID = timers[i].ID
break
end
end

local timerID = ID or os.startTimer( n )
local timerID = timer.new( n )
timers[#timers + 1] = { time = finish, response = response, ID = timerID }
return timerID
end
Expand Down

0 comments on commit 6df9de4

Please sign in to comment.