Different function

In lua, there are a few kind of function.

[lua]local function functionName(event)

local functionName = function(event)

function object:touch(event)

[lua]what is the differences? [import]uid: 40786 topic_id: 8384 reply_id: 308384[/import]

The first two are exactly the same. Lua just provides different ways of saying the same thing because while the second syntax is a little more descriptive of what’s actually happening (functions in Lua are all first-class objects that get put into variables) the first syntax looks more familiar to most programmers.

That third function is a method of the table “object.” When you stick a function into a table and call the function using a colon, then inside the function the keyword “self” refers to the table it belongs to. This is a methodology from object-oriented programming. [import]uid: 12108 topic_id: 8384 reply_id: 30030[/import]