Diff

util/timer.lua @ 4385:c94167139f27

util.timer: Fix corner case of timer not repeating if it returns <= 0
author Matthew Wild <mwild1@gmail.com>
date Thu, 22 Sep 2011 15:48:56 +0100
parent 3683:c2158221e2e6
child 4413:ffa4bed1b716
line wrap: on
line diff
--- a/util/timer.lua	Tue Sep 20 23:30:58 2011 +0100
+++ b/util/timer.lua	Thu Sep 22 15:48:56 2011 +0100
@@ -32,7 +32,10 @@
 		if delay >= current_time then
 			t_insert(new_data, {delay, func});
 		else
-			func();
+			local r = func();
+			if r and type(r) == "number" then
+				return _add_task(r, func);
+			end
 		end
 	end