Moving from Roblox

They have a wait() function built into their systems, is there a similar function for the Corona SDK?

It would work like

while true do

wait(1) --Delays code for 1 second

print(“Thing”)

end

also, why does this crash my game?

while true do

if thing == 1 then

elseif thing == 2 then

end

end

I’m not sure if this is what you’re asking, but you can use timer.performWithDelay(time, function, loops), there’s more about that here:

https://docs.coronalabs.com/api/library/timer/performWithDelay.html

The while loop doesn’t crash your game, per se… the loop just never ends. Graphics, input, etc. won’t get a chance to update. At some point the operating system will probably notice and react in some way, but the program itself is just stuck.

Rather than try too hard to mimic another SDK, you’ll probably make quicker progress just going all in learning Corona and Lua, and in particular Corona’s various control mechanisms, such as the timers mentioned by @zackrjoyce.

After that, if you’re still interested in going the wait() route, there are indeed ways you can do what you were asking, for instance as discussed recently here: wait or wait_for But it would be best to go into that already comfortable with the rest.  :slight_smile:

I’m not sure if this is what you’re asking, but you can use timer.performWithDelay(time, function, loops), there’s more about that here:

https://docs.coronalabs.com/api/library/timer/performWithDelay.html

The while loop doesn’t crash your game, per se… the loop just never ends. Graphics, input, etc. won’t get a chance to update. At some point the operating system will probably notice and react in some way, but the program itself is just stuck.

Rather than try too hard to mimic another SDK, you’ll probably make quicker progress just going all in learning Corona and Lua, and in particular Corona’s various control mechanisms, such as the timers mentioned by @zackrjoyce.

After that, if you’re still interested in going the wait() route, there are indeed ways you can do what you were asking, for instance as discussed recently here: wait or wait_for But it would be best to go into that already comfortable with the rest.  :slight_smile: