PDA

View Full Version : Need to read keyboard from within LUA



jdarnell
January 1st, 2006, 06:40 PM
I have read the online LUA programming tutorial. I have also been through much of these Proximis forums and cannot find a way to simply read keyboard input from within a LUA script. The only technique I find is to use the syntax...

io.stdin:read'*l'

Everytime I use this however I get an error similar to the following...

attempt to index global `io' (a nil value)
stack traceback:
1: main of string "?" at line 3

Can anyone help me?

Thanks!

Promixis
January 1st, 2006, 07:43 PM
Hi,

What are you trying to do? There are several ways to get user input.

jdarnell
January 2nd, 2006, 11:09 AM
Hi Mike and thanks for the quick reply! Basically I'm communicating through the parallel port and have written a quick LUA routine that simply toggles bits on the parallel port. I can toggle the bits on and off with no problem but I want to set a bit high and enter a timing loop where the loop will exit if either the time is up or the user presses a key on the keyboard. I would really prefer to do all of this within a LUA script.

If I can obtain the above it would be great. Ultimately though, I would REALLY like to be able to have some action occur if one of the bits on the parallel port goes high. I guess what I'm looking for is an interrupt driven scheme rather than simply polling for input. Any ideas? Thanks. I'll settle for polling if I can get my first question answered. Take care,

Jim

jdarnell
January 2nd, 2006, 11:28 AM
Hi Mike and thanks for the quick reply! Basically I'm communicating through the parallel port and have written a quick LUA routine that simply toggles bits on the parallel port. I can toggle the bits on and off with no problem but I want to set a bit high and enter a timing loop where the loop will exit if either the time is up or the user presses a key on the keyboard. I would really prefer to do all of this within a LUA script.

If I can obtain the above it would be great. Ultimately though, I would REALLY like to be able to have some action occur if one of the bits on the parallel port goes high. I guess what I'm looking for is an interrupt driven scheme rather than simply polling for input. Any ideas? Thanks. I'll settle for polling if I can get my first question answered. Take care,

Jim

Promixis
January 2nd, 2006, 03:03 PM
Jim,

You can catch keystrokes using the gir.AddEventHandler mechanism (see the manual) and catch input from the keyboard plugin.

Are you using dlportio plugin for the parallel port?