lua-users home
lua-l archive

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



Concerning this, is it possible in any way to read just one character, not whole line.

I mean, i'd like to have Y/n questions in scripts where pressing return wouldn't be necessary.

Most likely this falls into not having a good 'kbhit()' function available in ANSI C, and the issue since becoming platform dependent. Or has someone got good clues or code on this?

-ak


Peter Shook kirjoittaa sunnuntaina, 27. huhtikuuta 2003, kello 20:18:

Try the following:

$ cat test.lua

print'enter name:'
name = io.stdin:read'*l'
print('name',name)

print'enter age:'
age = io.stdin:read'*l'
print('age',age)

$ lua test.lua
enter name:
bill
name    bill
enter age:
5
age     5

- Peter Shook


Hi people,
I'm trying to write a simple program in Lua, but it's getting hard for me
to work with data input from keyboard. I've tryed to use de function
"read()" but I always get the following message:

../lua-5.0/bin/lua: teste.lua:2: attempt to call global `readfrom' (a nil
value)
stack traceback:
        teste.lua:2: in main chunk
        [C]: ?