Conditionals if then elseif else end

  • Lua has the standard forms of if and else
    • The syntax is not c or java like however

The form of the if statement is if conditional then -- your code goes here end The form of the if else statement is if conditional then -- your if code goes here else -- your else code goes here end

A simple example of all three statement types is given below

local number1 = 57 local number2 = 43 local number3 = number1 + number2 if number1 > number2 then print ("number1 is greater") end if number1 < number2 then print ("number2 is greater") else print ("number1 is greater") end if number3 < number1 then print ("number1 is greater than number3") elseif number3 < number2 then print ("number2 is greater than number3") else print ("number3 is greater than both of the other numbers") end