Wiki Page, Programming School: Lesson 5: Functions

Wiki Page
2017-01-27T17:57:32-07:00

Functions in Lua can be very useful. They allow you to handle information away from your current code, return values, and clean up your code a bit.

Functions can be defined in two ways. One way being:

'function name (x)

return x

end'

Or:

'name = function (x)

return x

end'

Both examples send back the information you sent to it. Not useful there, but they can do a lot!

Multiple parameters would be written like this:

'function name (x, y)

code

end'