Lua process control


Release date:2023-09-28 Update date:2023-10-13 Editor:admin View counts:214

Label:

Lua process control

Lua programming language flow control statements are set by the program to set one or more conditional statements. When the condition is true executes the specified program code when the condition is false executes other specified code.

The following is a typical flow chart of process control:

Image0

The conditional expression result of the control structure can be any value Lua believes that false and nil are false, true and non nil is true.

It should be noted that 0 in Lua is true:

Example

--[ 0 is true ]
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

If statement

If statement? It consists of a Boolean expression as a conditional judgment,followed by other statements.

If…else statement

If statement? Can you communicate with? Use else statement in combination, Execute the else statement code when the if conditional expression is false.

If nested statement

Can you do it in if? Or? use one or more if in else if? Or else if? Statement.

Powered by TorCMS (https://github.com/bukun/TorCMS).