Difference between revisions of "If"

Jump to navigation Jump to search
239 bytes added ,  09:08, 13 December 2009
imported>HawkFest
imported>Thalassicus
Line 80: Line 80:
=== Oblivion evaluates entire If statement ===
=== Oblivion evaluates entire If statement ===


Note also, that Oblivion evaluates all parts of an IF-statement. When you combine expressions with "&&" for example and the first expression is false, then the second one will still be evaluated.
Oblivion evaluates all the conditions for an IF statement. For example, when you combine expressions with "&&", if the first expression is false, later expressions will still be evaluated, even though they are irrelevant (false && anything = always false, true || anything = always true).


If ReferenceVariable != 0 && ReferenceVariable.Getav Health < 30
This can also result in unexpected errors, such as below:


Will crash Oblivion when the reference variable is undefined ("0"), because the second part is evaluated although the first part already returned "false". In such cases you need to use nested IF-blocks instead:
If (ReferenceVariable != 0) && (ReferenceVariable.Getav Health < 30)
 
This crashes Oblivion if the reference variable is undefined ("0"), because the second part is still evaluated. In such cases you need to use nested IF-blocks instead:


  If ReferenceVariable != 0
  If ReferenceVariable != 0
     If ReferenceVariable.Getav Health < 30
     If ReferenceVariable.Getav Health < 30
Since boolean conditions (&& ||) are inefficient and implemented poorly in Oblivion, use nested IF-blocks whenever possible.


== Comparisons and Expressions ==
== Comparisons and Expressions ==
Anonymous user

Navigation menu