Can't get performWithDelay working

Hello everyone, I’m new to Corona SDK and enjoying it tremendously. I’ve learned a great deal on my own, but I keep hitting a wall with performWithDelay.

As I understand it, it should work like this:

timer.performWithDelay( milliseconds, functionCalled, iterations )

function functionCalled()

       print(“This should print to the console as many times are there are iterations at the rate of the milliseconds”)

end

I may be wrong, but this is how I understand it so far. I’m trying to make a simple timer that counts up indefinitely, but I can’t get the timer to do anything. I’ve dumbed it all down to this, just to see if it works:

timer.performWithDelay( 1000, timeKeeper, 5 )

function timeKeeper()

      print(“test”)

end

I expect to see test written to the console 5 times. I’m not even seeing it once. I’ve looked at a number of resources online but they all seem to imply that this should be working. Clearly I’m missing something basic, and I regret bothering you with this problem, but I’d really appreciate the help!

Thank you :slight_smile:

The timeKeeper function is not in scope for the timer.

It will work if you move the function up above the timer.

Might be helpful to read up on Lua scoping. 

It looks like that did the trick, thanks for the help! I’ll make sure to go over scoping again.

I appreciate it!

The timeKeeper function is not in scope for the timer.

It will work if you move the function up above the timer.

Might be helpful to read up on Lua scoping. 

It looks like that did the trick, thanks for the help! I’ll make sure to go over scoping again.

I appreciate it!