Difference between revisions of "If"

Jump to navigation Jump to search
181 bytes removed ,  11:41, 15 June 2006
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


 
Additional Notes:
== Notes ==
Script parser seems to have problems with one-lined else statements. I personally observed how a line
Keep in mind that the script parser doesn't accept one-lined statments. While
  else set varname to somevalue ;(exactly: else set MTseason to 1)
 
caused the script to ignore it completely (MTseason always stayed at 0). Changing it to  
  if condition==1 set varname to 1
  else  
else set varname to 2
   set varname to somevalue
 
immediately solved the problem. I guess you can also use parentheses to enclose the action part of the statement.
works in other programming languages, you need to split this up for Oblivion.
I'm writing this because many programming and scripting languages let you use the original version of the statement without similar problems. You should also know is that there won't be any error messages to warn you, so (since the line appears to be correct) you may spend a lot of time locating the source of the problem.  
 
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]]
Anonymous user

Navigation menu