local clock = os.clock function sleep(n) -- seconds local t0 = clock() while clock() - t0 <= n do end end -- warning: clock can eventually wrap around for sufficiently large n -- (whose value is platform dependent). Even for n == 1, clock() - t0 -- might become negative on the second that clock wraps.
function sleep(n) os.execute("sleep " .. tonumber(n)) end
require "socket" function sleep(sec) socket.select(nil, nil, sec) end sleep(0.2)
Sent from my Verizon Wireless BlackBerry
Hi list,
is there a sleep function that is
- non-busy
- allows for ctrl-C
- doesn't get stuck
- does not require a C extension
I tried busy, system call and sockets from http://lua-users.org/wiki/SleepFunction for the above reasons they don't work for me.
Is there a rock offering a simple C-programmed sleep?
It's for a very simple game world tick with the focus on demonstrating (other) principles, and ease of getting to run oneself.
Thanks,
Henning