diff --git a/src/factory.c b/src/factory.c index e0e9f7b9..cb695cd1 100644 --- a/src/factory.c +++ b/src/factory.c @@ -949,21 +949,74 @@ int L_MessageBox(lua_State* L) return 0; } -int L_Sleep(lua_State* L) +int L_Wait(lua_State* L) { - int delay; + float delay; Uint32 end; int nb_args=lua_gettop(L); - LUA_ARG_LIMIT (1, "sleep"); - LUA_ARG_NUMBER(1, "sleep", delay, 0, 10000); + LUA_ARG_LIMIT (1, "wait"); + LUA_ARG_NUMBER(1, "wait", delay, 0.0, 10.0); - end = SDL_GetTicks()+delay; + // Simple 'yield' + if (delay == 0.0) + { + Get_input(0); + return 0; + } + // Wait specified time + end = SDL_GetTicks()+(int)(delay*1000.0); do { Get_input(20); } while (SDL_GetTicks()