Lua does not provide a standard sleep function, but there are several ways to implement it, see Sleep Function for details.
For Linux, this might be the easiest:
function sleep(n) os.execute("sleep " .. tonumber(n)) end
On Windows, you can use ping :
function sleep(n) if n > 0 then os.execute("ping -n " .. tonumber(n+1) .. " localhost > NUL") end end
Anyone who uses select deserves some attention because this is the only portable way to get sub-seasonal resolution:
require "socket" function sleep(sec) socket.select(nil, nil, sec) end sleep(0.2)
source share