Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In Lua, you can compare two variables to see if they are equal using the == equality operator. For instance:

Code Block
languagelua
-- single = to assign values to variables
local Variable1 = "Fred"
local Variable2 = "Mary"
local Variable3 = "Fred"

if (Variable1 == Variable3) then
  trace("These variables are equal!")
end

See Using trace() function Below are the comparison operators you can apply to compare variables:

== Equal to

~= Not equal to

< Less than

> Greater than

<= Lesser or equal to

>= Greater or equal to

See if statements for a simple example of applying these comparison operators.