Help

I am a massive noob and need help!

I want to make a keyboard and I followed the directions given by codea to the letter but it wants a string value for textMode can anyone give me an example of this

As in

textMode(CENTER)

Is that what you’re asking?

textMode accepts either the parameter CORNER or CENTER (not as a string — these are constants defined in Codea).

So for example you can call either of the following to set the text mode:

textMode(CORNER)
textMode(CENTER)

Note that textMode only affects how text is rendered with the text() function.

Thanks @simeon

For some reason it comes up with the same error (it still wants a string) is there any other thing I may have done wrong

Mike, can you post your code?

Don’t worry I worked it out #:-s

Hey me again how do I make a keyboard write text?

You’ll need to add the keyboard function to your main. Then, assuming you’ve already displayed the keyboard, you can do something like this.

function keyboard(key)
    if key ~= nil then
       if string.byte(key) == 10 then
        -- do something with return
        elseif string.byte(k) == nil then
        -- handle backspace
            if string.len(myString) > 0 then
                myString = string.sub(myString, 1, string.len(myString) - 1)
            end
        else
        -- add a character 
            myString = myString + key
        end
    end
end

That won’t really display your text. To do that, you’ll need to add a line to your draw function along the lines of

    text(myString, 50, 500)

So the keyboard function captures key presses and puts them in a string, while the draw routine displays them. Make sense?

You’ll find textbox routines in several of the projects shared in the forum, as well as in the sample project Spritely. You might find one of these handy.

Try this one: http://twolivesleft.com/Codea/Talk/discussion/comment/8697#Comment_8697

Hi still working on my keyboard thingy and can’t workout how to get the enter key to make a new line of text underneath the other