Hi,
I was diving into Corona documents reading bits about this and that here and there that I stumbled upon this:
[lua] local t = {}
function t:timer( event )
local count = event.count
print( “Table listener called " … count … " time(s)” )
if count >= 3 then
timer.cancel( event.source ) – after 3rd invocation, cancel timer
end
end
– Register to call t’s timer method an infinite number of times
timer.performWithDelay( 1000, t, 0 )[/lua]
What caught my eye is the second line, the definition line: function t:timer( event )
It may be simple but since I’m new to LUA (and dynamic languages, beside my old experiences with AS2, 3) I could understand what does that double colon mean. My best guess was that it added this timer to that “t” table but since there was no add statement, I highly doubt it.
I Googled around and read more than 20 tutorials on function definition in LUA but none of them had this, so it has to be with something else, like that table “t” for example.
Thanks and sorry if this is a simple question, but we are in the n00b section! :] [import]uid: 206803 topic_id: 34764 reply_id: 334764[/import]
[import]uid: 62706 topic_id: 34764 reply_id: 138129[/import]