YouTip LogoYouTip

Lua Decision Making

# Lua Flow Control The flow control statements in the Lua programming language are set by specifying one or more conditional statements in the program. When the condition is true, the specified program code is executed; when the condition is false, other specified code is executed. Here is a typical flow control flowchart: ![Image 2: Lua Flow Control](#) The result of the conditional expression in a control structure can be any value. Lua considers false and nil as false, and true and non-nil as true. Note that in Lua, 0 is considered true: ## Example -- if(0) then print("0 is true") end The output of the above code is: 0 is true Lua provides the following control structure statements: | Statement | Description | | --- | --- | | (#) | The **if statement** consists of a boolean expression as a condition, followed by other statements. | | [if...else statement](#) | The **if statement** can be used with the **else statement**. The else statement code is executed when the if condition expression is false. | | (#) | You can use one or more **if** or **else if** statements inside an **if** or **else if** statement. |
← Cpp NamespacesLua File Io β†’