Difference between revisions of "Basic lua: Operators"
From The Official Visionaire Studio: Adventure Game Engine Wiki
Line 12: | Line 12: | ||
|} <br/> | |} <br/> | ||
− | Example 1: | + | Example 1: <span class="blue">if</span> condition is <span style="color:green">true</span>... |
{| class="tbl-alt" | {| class="tbl-alt" | ||
|- | |- | ||
Line 24: | Line 24: | ||
end | end | ||
</syntaxhighlight> || width="200px" | [[File:lb_operators_001.png|thumb|right|180px|click to enlarge]] | </syntaxhighlight> || width="200px" | [[File:lb_operators_001.png|thumb|right|180px|click to enlarge]] | ||
+ | |} | ||
+ | |||
+ | Example 2: <span class="blue">if</span> condition is <span style="color:green">true</span>... (alternative) | ||
+ | {| class="tbl-alt" | ||
+ | |- | ||
+ | | <syntaxhighlight> | ||
+ | local a = true | ||
+ | |||
+ | if a == true then | ||
+ | print("a = true") | ||
+ | else | ||
+ | print("a = false") | ||
+ | end | ||
+ | </syntaxhighlight> || width="200px" | [[File:lb_operators_002.png|thumb|right|180px|click to enlarge]] | ||
|} | |} |
Revision as of 23:43, 18 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 unless elseif has been used |
Example 1: if condition is true...
local a = true
if a then
print("a = true")
else
print("a = false")
end |
Example 2: if condition is true... (alternative)
local a = true
if a == true then
print("a = true")
else
print("a = false")
end |