Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Lua Functions

Lua Functions

In Lua, functions are the main method of abstracting statements and expressions. They can be used to handle some special tasks, and can also be used to calculate some values.

Lua provides many built-in functions that you can conveniently call in your programs. For example, the print() function can print the passed arguments to the console.

Lua functions have two main uses:

Function definition

The function definition format in the Lua programming language is as follows:


optional_function_scope function function_name( argument1, argument2, argument3..., argumentn)
    function_body
    return result_params_comma_separated
end

Analysis: