Difference between revisions of "If"
Jump to navigation
Jump to search
gave it a more professional look
imported>Max m (minor correction) |
imported>JOG (gave it a more professional look) |
||
Line 1: | Line 1: | ||
The <tt>if</tt> statement allows you to execute (or not execute) a block of script commands based on one or more comparisons that you specify. Oblivion's <tt>if</tt> command is very powerful and comparable to "real" programming languages. | The <tt>if</tt> statement allows you to execute (or not execute) a block of script commands based on one or more comparisons that you specify. Oblivion's <tt>if</tt> command is very powerful and comparable to "real" programming languages. | ||
== Overview == | == Overview == | ||
Line 16: | Line 17: | ||
The <tt>else</tt> and <tt>elseif</tt> statements are optional. | The <tt>else</tt> and <tt>elseif</tt> statements are optional. | ||
== Comparison Operators == | == Comparison Operators == | ||
Line 46: | Line 48: | ||
It is important to note that there are no bitwise comparisons available in Oblivion's scripting language. | It is important to note that there are no bitwise comparisons available in Oblivion's scripting language. | ||
== Combining Comparisons == | == Combining Comparisons == | ||
Line 78: | Line 81: | ||
This is true when either myVar2 is 5 OR both, myVar1 and myVar2 are 1 | This is true when either myVar2 is 5 OR both, myVar1 and myVar2 are 1 | ||
== Comparisons and Expressions == | == Comparisons and Expressions == | ||
Line 108: | Line 112: | ||
IF IsActor != 0 && Flag != 0 | IF IsActor != 0 && Flag != 0 | ||
== Notes == | |||
Keep in mind that the script parser doesn't accept one-lined statments. While | |||
if condition==1 set varname to 1 | |||
else | else set varname to 2 | ||
set varname to | |||
works in other programming languages, you need to split this up for Oblivion. | |||
if condition==1 | |||
set varname to 1 | |||
else | |||
set varname to 2 | |||
endif | |||
(it's better readable too...) | |||
After the condition or the "else" statement the rest of the line is ignored, and there aren't any error messages to warn you, so (since the line appears to be correct) you might spend a lot of time locating the source of the problem. | |||
[[Category:Commands]] | [[Category:Commands]] |