Difference between revisions of "Basic lua: Operators"
From The Official Visionaire Studio: Adventure Game Engine Wiki
Line 13: | Line 13: | ||
− | Example 1: if condition is true (method 1) | + | {| class="ts" |
− | + | |- | |
+ | ! colspan="2" | Example 1: if condition is true (method 1) | ||
|- | |- | ||
| <syntaxhighlight> | | <syntaxhighlight> | ||
Line 25: | Line 26: | ||
|} | |} | ||
− | Example 2: if condition is true (method 2) | + | {| class="ts" |
− | + | |- | |
+ | ! Example 2: if condition is true (method 2) | ||
|- | |- | ||
| <syntaxhighlight> | | <syntaxhighlight> | ||
Line 38: | Line 40: | ||
{| class="ts" | {| class="ts" | ||
− | |- | + | |- |
! Example 3: if condition is false (method 1) | ! Example 3: if condition is false (method 1) | ||
|- | |- | ||
Line 50: | Line 52: | ||
|} | |} | ||
− | Example 4: if condition is false (method 2) | + | {| class="ts" |
− | + | |- | |
+ | ! Example 4: if condition is false (method 2) | ||
|- | |- | ||
| <syntaxhighlight> | | <syntaxhighlight> |
Revision as of 15:02, 20 August 2014
Lua operators are expressions used to perform calculations or to pass arguments between different value types.
Conditional Operators
if | Query if something does or does not meet a certain condition. |
else | Do something else if the query condition was not met. |
elseif | Used to add additional if queries, if the initial query condition was not met. |
end | This is used to close various queries or functions; there must be the same amount of end as if; except in instances where elseif has been used. |
Example 1: if condition is true (method 1) | |
---|---|
local a = true
if a then
print("a = true")
end |
Example 2: if condition is true (method 2) | |
---|---|
local a = true
if a == true then
print("a = true")
end |
Example 3: if condition is false (method 1) | |
---|---|
local a = false
if not a then
print("a = false")
end |
Example 4: if condition is false (method 2) | |
---|---|
local a = false
if a == false then
print("a = false")
end |