diff options
Diffstat (limited to 'src/l_timer.c')
-rw-r--r-- | src/l_timer.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/l_timer.c b/src/l_timer.c index dfe3135..c63f865 100644 --- a/src/l_timer.c +++ b/src/l_timer.c @@ -113,7 +113,7 @@ static int l_timer_cmp(lua_State *L) return 1; } -static const struct luaL_reg timer_funcs [] = { +static const struct luaL_Reg timer_funcs [] = { { "new", l_timer_new }, { "now", l_timer_now }, { "add", l_timer_add }, @@ -124,6 +124,13 @@ static const struct luaL_reg timer_funcs [] = { LUALIB_API int luaopen_timer(lua_State *L) { - luaL_register(L, LUA_TIMERLIBNAME, timer_funcs); +#if LUA_VERSION_NUM > 501 + lua_newtable(L); + luaL_setfuncs(L, timer_funcs, 0); + lua_pushvalue(L, -1); + lua_setglobal(L, LUA_TIMERLIBNAME); +#else + luaL_register(L, LUA_TIMERLIBNAME, timer_funcs); +#endif return 1; } |