'if' and looping questions

Hello, My name’s Geoff, I’m new to the forums and I have no experience with Corona or LUA. I have a bit of experience with Java and C.

I have an object transitioning upward to y = 500, but I want it to instantly change it’s y coordinate to 0 once it’s higher than 400. What’s the best way to do that?
I tried creating a while loop with an if condition:

while action == 1 do
if object.y > 400 then
object.y = 0
end
end

…but that crashes. Any advice? [import]uid: 34108 topic_id: 8498 reply_id: 308498[/import]

Lua is single threaded, so by doing that you’re locking up all the processing time in that function. You should use the runtime event ‘enterframe’ and check in every frame what the y value is.

I assume you simplified what you wan to do, otherwise why not transition to 400 and use onComplete to do what you want to do. [import]uid: 8872 topic_id: 8498 reply_id: 30444[/import]