diff --git a/src/factory.c b/src/factory.c index 2f30e7f6..b310f577 100644 --- a/src/factory.c +++ b/src/factory.c @@ -1007,6 +1007,52 @@ int L_WaitBreak(lua_State* L) return 1; } +int L_WaitInput(lua_State* L) +{ + float delay; + Uint32 end; + int nb_args=lua_gettop(L); + int moved; + + /*word key; + word button; + word mouse_x; + word mouse_y;*/ + + LUA_ARG_LIMIT (1, "waitinput"); + LUA_ARG_NUMBER(1, "waitinput", delay, 0.0, DBL_MAX); + + // Simple 'yield' + if (delay == 0.0) + { + moved=Get_input(0); + } + else + { + // Wait specified time + end = SDL_GetTicks()+(int)(delay*1000.0); + + moved=0; + do + { + moved=Get_input(20); + } while (!moved && SDL_GetTicks()