[Help] Touch

So I have been trying to develop my first app using Codea. Well I am stuck. I have designed a 4-digit passcode lock to gaurd the app the only trouble I have had is getting the touch recognition to work. What I need is for it to recognize what number I pressed and react the right way if it’s the right code or not. I hope I have explained this well enough. Thanks in advance!

Photo of the 4-digit passcode:
http://imgur.com/wbXxa53

@iColor Here’s an example. Not exactly like yours, but the code might help.


displayMode(FULLSCREEN)

function setup()
    number=""
end

function draw()
    background(40, 40, 50)
    count=0
    for y=4,1,-1 do
        for x=1,3 do
            count=count+1
            if count<10 or count==11 then
                fill(255)
                ellipse(x*100,y*100,100)
                fill(255,0,0)
                val=count
                if count==11 then
                    val=0
                end
                text(val,x*100,y*100) 
            end           
        end
    end
    text(number,WIDTH/2,HEIGHT/2)
end

function touched(t)
    if t.state==BEGAN then
        number=0
        for y=4,1,-1 do
            for x=1,3 do
                xc=x*100
                yc=y*100
                number=number+1
                if (t.x-xc)^2/50^2+(t.y-yc)^2/50^2 <= 1 then 
                    if number==11 then
                        number=0
                    end
                    return
                end
            end
        end
        number=""
    end
end

Holy poo. Could I by chance message you my code so you could see if that would work with my code? I can’t look at that and understand it.

Yes.