fucntion arguments

If i want to have a listener function or a function inside timer.performWithDelay take arguments how do I do this?

right now if i do object:addListener(‘tap’,function(arg1,agr2)) i get errors. Or if I do timer.performWithDelay(100000, fucntion(arg1,arg2),1) the function performs instantly with no delay.

Hello misterk6,

Hope you are doing well.

I believe i had already done this kind of stuff before as far as i understood from your question.

If you are trying to pass a parameter in timer function here is the link i am attaching please have glance on it.

http://stackoverflow.com/questions/16597772/passing-arguments-through-timer-performwithdelay-lua

http://www.ludicroussoftware.com/blog/2011/09/05/passing-parameters-in-a-timer/.

I think this may helps…

Thanks & regards

Neel. :P  :wink:

@misterk6, nilstar141 has pointed you in the right direction.  Just be aware, performWithDelay() is taking a reference to a function (Note this is fully documented in the online docs, including an example of closures):

timer.performWithDelay( delay, functionRef, repeats )

So, to execute your code you need to utilize a closure (temporary function created for the task):

 timer.performWithDelay( 100000, function() -- start of closure yourFunc( arg1 , arg2 ) end -- end of closure ), 1) 

or, in one line: 

 timer.performWithDelay( 100000, function() yourFunc( arg1 , arg2 ) end ), 1)

Hello misterk6,

Hope you are doing well.

I believe i had already done this kind of stuff before as far as i understood from your question.

If you are trying to pass a parameter in timer function here is the link i am attaching please have glance on it.

http://stackoverflow.com/questions/16597772/passing-arguments-through-timer-performwithdelay-lua

http://www.ludicroussoftware.com/blog/2011/09/05/passing-parameters-in-a-timer/.

I think this may helps…

Thanks & regards

Neel. :P  :wink:

@misterk6, nilstar141 has pointed you in the right direction.  Just be aware, performWithDelay() is taking a reference to a function (Note this is fully documented in the online docs, including an example of closures):

timer.performWithDelay( delay, functionRef, repeats )

So, to execute your code you need to utilize a closure (temporary function created for the task):

 timer.performWithDelay( 100000, function() -- start of closure yourFunc( arg1 , arg2 ) end -- end of closure ), 1) 

or, in one line: 

 timer.performWithDelay( 100000, function() yourFunc( arg1 , arg2 ) end ), 1)