--- a/lua.c Mon Mar 21 02:04:02 2016 +0200
+++ b/lua.c Sat Jul 30 05:04:35 2016 +0300
@@ -1210,10 +1210,10 @@
/// mcabber.timer
/// Creates new timer function, that will be called periodically.
-/// A: integer (interval, seconds), timer function
+/// A: float (interval, seconds), timer function
static int lua_main_timer (lua_State *L)
{
- int interval = luaL_checkinteger (L, 1);
+ lua_Number interval = luaL_checknumber (L, 1);
guint source;
lua_timer_callback_t *cb;
luaL_argcheck (L, lua_isfunction (L, 2), 2, "function expected");
@@ -1222,7 +1222,11 @@
cb->reference = luaL_ref (L, LUA_REGISTRYINDEX);
cb->L = L;
- source = g_timeout_add_seconds_full (MLUA_SOURCE_PRIORITY, interval, (GSourceFunc) lua_timer_callback, cb, (GDestroyNotify) lua_timer_callback_destroy);
+ source = g_timeout_add_full (MLUA_SOURCE_PRIORITY,
+ (guint) ( interval*1000 ),
+ (GSourceFunc) lua_timer_callback,
+ cb,
+ (GDestroyNotify) lua_timer_callback_destroy);
cb->source = source;
lua_timers = g_slist_prepend (lua_timers, (gpointer) ((gsize) source));