There is unfortunately no os.sleep()
. But most platforms have a function call that can make a script suspend execution for a time period. This consumes no processor time, unlike a 'busy loop' which should be avoided.
LuaSocket provides a socket.sleep
function which is passed the number of seconds to sleep; this is a floating-point number so it may be less than a second.
For Windows, Winapi provides a sleep
function.
It is straightforward to bind to platform-specific sleep functions using LuaJIT FFI.