lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


May luasocket's gettime function will help you.

> require'socket'
> =socket.gettime()
1222222809.1984
>

luasocket 2.0.2

On Tue, Sep 23, 2008 at 8:16 PM, Shmuel Zeigerman <shmuz@013net.net> wrote:
I have an interactive Lua script that prompts user with a question and waits for an answer string from the standard input. The script measures the time it takes user to enter the answer, and the measurement should have 100 ms accuracy (or better).

Under Windows, it's achieved trivially by calling os.clock twice and subtracting the first value from the second. However, under Linux, the function returns 0 both times.

The questions:

1. How can I get time intervals of waiting for keyboard input measured with the 100 ms accuracy under Linux?

2. Is there a Lua solution to this problem that is portable between (at least) Linux and Windows?

Thanks.
--
Shmuel



--
Regards,
Linker M Lin
linker.m.lin@gmail.com