timer.performWithDelay usage

Hi all.
I had real problems using timer.performWithDelay, I searched through the forums etc with no luck, and it was only as I was doing some daydreaming at work the solution hit me.
My problem was passing variables.
All the examples I saw basically said to use the delay variable in the animation functions, but I found this cumbersome and of course only works for animations…

For ex [lua]timer.performWithDelay(10,print(“Test”),10)[/lua] doesn’t work, it evals instantly, and doesn’t delay or repeat.
I thought about going to crazy lengths to fix this, including tables full of parameters to parse.

BUT
This works great!
[lua]pt = function() print(“Test”) end
timer.performWithDelay(10,pt,10)[/lua]

And even better

[lua]timer.performWithDelay(10,function() print(“test”) end,10)[/lua]

If anyone can tell my why I shouldn’t use this, please do :slight_smile:
Or am I just daft, and everyone does this without thinking, hence the lack of documentation :stuck_out_tongue:
[import]uid: 34945 topic_id: 8846 reply_id: 308846[/import]

I believe your first example, the one which points to the pt function rather than defining the function within the timer itself performs better, but they do the same thing.

Also remember that timer.performWithDelay works with milliseconds… so 10 milliseconds is pretty much going to do something–seemingly–in an instant. [import]uid: 52430 topic_id: 8846 reply_id: 32403[/import]