From 5c3d4163d3691d74ce6f0f9f7f469de6ea20b652 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Tue, 16 Jun 2020 14:53:01 +0200 Subject: [PATCH] Modify system.wait_event to wait indefinitely if no timeout is given --- src/api/system.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/api/system.c b/src/api/system.c index 235d5824..bb8aa40d 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -133,8 +133,13 @@ top: static int f_wait_event(lua_State *L) { - double n = luaL_checknumber(L, 1); - lua_pushboolean(L, SDL_WaitEventTimeout(NULL, n * 1000)); + int nargs = lua_gettop(L); + if (nargs >= 1) { + double n = luaL_checknumber(L, 1); + lua_pushboolean(L, SDL_WaitEventTimeout(NULL, n * 1000)); + } else { + lua_pushboolean(L, SDL_WaitEvent(NULL)); + } return 1; }