What are functions?

Functions can carry out a procedure or compute and return values. We can make a function call as a statement, or we can use it as an expression. You can also use object methods as functions. You have learned that functions can be variables. A table can use these variables to store them as properties.

Functions are the most important means of abstraction in Lua. One function that we have used many times is print. In the following example, the print function is being told to execute one piece of data—the "My favorite number is 8" string:

print("My favorite number is 8") -- My favorite number is 8

Another way of saying this is that print is being called with one argument. The print function is only one of the many built-in functions that Lua has, but almost any program you write will involve you defining your own functions.

When trying to define a function, you have to give it a name that you can call out to when you want to return a value. You then have to create a statement or statement block of what the value will output and then apply end to your function after you have finished defining it. Here is an example:

Notice that the function name is myName, and it is used to call out what's inside the print("My name is Jane.") function definition.

An extension on defining a function is as follows:

The new myName function has one argument using the Name variable. The "My name is " string is concatenated with Name and then a period as the printed result. When the function is called, we used three different names as an argument, and the result is printed with a new customized name for each line.

In Corona, you can change the appearance of the status bar on your device. This is a one-line setting in your code that takes effect once you launch your application. You can change the appearance of your status bar using the display.setStatusBar(mode) method. This hides or changes the appearance of the status bar on iOS devices (iPad, iPhone, and iPod Touch) and Android 2.x devices. Android 3.x devices are not supported.

The argument mode should be one of the following: