LUA Projects > Code Sharing - "Snipits"

LUA First question: Keyboard events....

(1/1)

RayS:
This is more abstract and deals with functionality.

I downloaded the SimInnovation gauge suite and it's all based on LUA programming.

Does LUA have a library/facility to work with keyboard events? I see facilities for Joystick events which has me thinking. With regard to rotary encoders, they need to be spun with some vigor sometimes. My concern is that if the rotaries use joystick events, that the overall joystick architecture will end up missing a lot of those button events, while my experience has shown that working with keyboard events is a lot cleaner.

Can anyone share their experiences?

Trevor Hale:
Ray,

Lua itself does not natively accept inputs. But like arduino there are library's you can import.

Take a look at the io library, which by default has standard-input as the default input file:

http://www.lua.org/pil/21.1.html


--- Quote ---local answer
repeat
   io.write("continue with this operation (y/n)? ")
   io.flush()
   answer=io.read()
until answer=="y" or answer=="n"

--- End quote ---

Trev

Navigation

[0] Message Index

Go to full version