An assortment of questions.

Hi all,
I’m a beginner, so don’t judge.
I want to use the touched() function for a character to be moved. However, when the finger is on the screen, but not moving the touched function is not called. Is there an easy way to fix this?
Thanks.

if touch.state ~= ENDED then
    --move player code
end

@MattthewLXXIII Here you go! Just create a variable like tch that saves the data from your touched() function. Then you can use that variable in draw()

function setup()
    tch = nil
end

function draw()
    background(40, 40, 50)
    strokeWidth(5)
    
    if tch then 
        ellipse(tch.x,tch.y,100) 
        -- Add the rest of your code here
    end
end

function touched(touch)
    if touch.state == ENDED then
        tch = nil
    else
        tch = touch
    end
end

Thanks guys!
What is ~=?
Is there a way I can change the title to ask a different question?

The ~= is not equal. Just ask your new question here.

What is != then?
Is there a way to receive input from a bluetooth keyboard?
Thanks.

!= is also not equal, but not in Lua.

Ah, ok.
Do you know the answer to my second question?

Search this forum

Fair enough, thank you.
How do you access the y value on the unpack?

This forum isn’t a substitute for reading the reference material on Lua and Codea.

It’s fair enough to ask if you get stuck, but asking what ~= means, or about the different states of the touched function, or how unpack works, is wasting our time because they are explained in the Codea reference or in the Lua manual. If you don’t understand the explanations there, ask, but please read them first.

I’ll concede the ~= and the keyboard, but I’m confused about the unpack() function. It returns 2 values, but when you compare it, it only uses the x value. What is the Lua manual? @Ignatz you don’t have to answer.

You can’t compare a list of two values with something else. It’s basically saying

If x,y~=z then

Which is obviously invalid

This is what unpack is for

a=vec2(1,3)
translate(a:unpack())

For the Lua manual, try google ((Codea is built on the Lua language)

Thanks, but is there a function not involving dot product to get the x and y values for a vector?
EDIT: (individually)

The “dot notation” (nothing to do with dot product) returns the components of a vector. Eg pos.x. So translate(pos:unpack()) is the same as translate(pos.x, pos.y, pos.z) EDIT: or translate(pos.x, pos.y) depending on whether pos is vec2 or vec3

Hmmm, back tick inline code not working on Codea Talk?

Thanks @yojimbo2000.

please learn the Lua language, then you won’t need to ask these basic questions

I have written posts and ebooks that may help

https://coolcodea.wordpress.com/2013/06/19/index-of-posts/

How do I tell if the keyboard is not being pressed? The keyboard function appears to return the last key which was pressed as opposed to what is being pressed at that moment.