Arguments and Return Values
Functions in Lua can take arguments and return values. The syntax is simple and similar to many other scripting languages.
Function with Parameters:
function add(a, b)
return a + b
end
Calling It:
sum = add(5, 3)
print(sum) -- Output: 8
Multiple Return Values:
Lua supports returning multiple values from a function:
function getCoordinates()
return 10, 20
end
x, y = getCoordinates()
print(x, y) -- Output: 10 20