Functions

A function is a group of statements that carry out a specific task (procedure) or a function can calculate and return values.

function myFunction(name)
print( ' Hello ' .. name)
var1 = 100
local var2 = 99
return "returns nil if you don ' t have a return statement."
end
myFunction( ' Feko user ' )
print(var1) -- prints 100
print(var2) -- prints nil, since var2 does not exist outside the function

It is important to note the scope of any local and global variable definitions.

Tip: Use local variable definitions as far as possible.