

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I get the idea of parameters in functions, but I don't know what an event is. I have also heard of JavaScript function events but since I have no js experience, I don't know what they are.

share|improve this question
Do you mean the events discussed in ? – lhf Nov 10 '11 at 17:39
up vote 2 down vote accepted

There is nothing special in Lua that can be called 'event'. I guess you are talking about general events (from Wikipedia):

In computing an event is an action that is usually initiated outside the scope of a program and that is handled by a piece of code inside the program

An example of events are a mouse click, key press, download finished, anything you can imagine.

In order to react to an event, you need to write a so-called handler, sometimes also called listener or callback, which is a piece of code that you register to react to a certain event. The available events, handling process and handler registration are all dictated by the library/framework you are using, i.e. it's not Lua specific, but Lua does provide functions as way to write handlers.

For example, in Corona SDK (overview of events/listeners), you can handle the 'touch' event as follows:

Runtime:addEventListener("touch", function(event)
    print("A touch event is being handled")
share|improve this answer

There is no such thing as an 'event' in a standard Lua function. Perhaps there is some library that provides you with them, or you could script your way around to emulate the wanted behaviour.

You can get more concrete answers if you provide info about what you want to accomplish, and show some code.

share|improve this answer

Your Answer


