Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Simple Keyboard Input and Output

edited April 2012 in Questions Posts: 1

I'm quite the n00b when it comes to Lua on the iPad. Can anyone help me with this seemingly simple problem? I want a simple program that will ask me to type my name on the keyboard and will then say "hello" to me. In pseudo code this might look like:

a = prompt("What is your name?")
print("Hello, " a, " nice to meet you.")

Thank you in advance for your help.


  • Posts: 78

    Please check this out.

    function setup()     print("Touch to show Keyboard\nand press return to show a message")     a = "What is your name?"     said = false end function draw()     background(255)     textMode(LEFT)     text(a,100,600)     w,h = textSize(a)     if not said then         n = keyboardBuffer()     end     if n then         text(n,100+w+10,600)     end     if said then         text("Hello "..n.." nice to meet you.",100,600- h)     end end function touched(touch)     if touch.state==ENDED then         showKeyboard()         said = false     end end function keyboard(key)     if key == "\n" then         hideKeyboard()         said =true     end end 
Sign In or Register to comment.