Lua is a lightweight and compact scripting language, written in standard C language and open in source code form. It is designed to be embedded in applications to provide flexible expansion and customization functions for applications.
Lua functions syntax
In Lua, functions are the main method of abstracting statements and expressions. It can be used to handle some special tasks and to calculate some values.
Lua provides many built-in functions that you can easily call in your program. For example, the print() function can print the passed parameters on the console.
Lua functions have two main uses:
1. Complete the specified task, in which case the function is used as a calling statement;
2. Calculate the union Returns a value, in which case the function is used as an expression in an assignment statement.
Lua functions example
--[[ function returns the maximum of two values --]]function max(num1, num2) if (num1 > num2) then result = num1; else result = num2; end return result; end-- call function Print("The maximum value compared between two values is ",max(10,4)) Print("The maximum value compared between two values is ",max(5,6))