This article mainly introduces the use of IF statements nested in Lua tutorial, is the basic knowledge in LUA learning, the need for friends can refer to the
Programming inline If-else Statements in Lua means that you can use an if or else if in another statement if or else if statement.
Grammar
The nested syntax for the IF statement is as follows:
The code is as follows:
if (Boolean_expression 1)
Then
--[executes when the Boolean expression 1 is true--]
if (Boolean_expression 2)
Then
--[executes when the Boolean expression 2 is true--]
End
End
You can nest else if...else in a way that resembles an if statement.
Example:
The code is as follows:
--[local variable definition--]
A = 100;
b = 200;
--[Check the Boolean condition--]
if (a = = 100)
Then
--[if condition is true then check the following--]
if (b = = 200)
Then
--[if condition is true then print the following--]
Print ("The Value of A is-B is 200");
End
End
Print ("Exact value of A is:", a);
Print ("Exact value of B is:", b);
When the above code is built and run, it produces the following results.
The code is as follows:
Value of A is and B are 200
Exact value of a is:100
Exact value of B is:200