Difference between revisions of "If"
→Oblivion evaluates entire If statement
imported>HawkFest |
imported>Thalassicus |
||
Line 80: | Line 80: | ||
=== Oblivion evaluates entire If statement === | === Oblivion evaluates entire If statement === | ||
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). | |||
This can also result in unexpected errors, such as below: | |||
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 == |