Difference between revisions of "If"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Simetrical
m (Reformat)
imported>Simetrical
m (IF moved to If)
(No difference)

Revision as of 20:18, 4 April 2006

Oblivion's if command is very powerful and comparable to "real" programming languages. The expressions to test on can be very complex:

Assuming "a = 17", "b = 20" and "c = a - b", all of the following expressions work as expected. Parentheses are only needed when they're necessary for mathematical reasons.

IF c == -3 && b == 20
IF c == -3 && b == 20 && a == 17
IF c - 1 == -4 && b == 20 && a == 17
IF a - 20 == 17 - b
IF a - 20 == 17 - b && c + 3 == 0
IF a + 3 == b
IF a - b == c
IF a *4 - b * 4 == c * 4
If a * ( 5 + c ) - 14 == b
If 2*(a*(5+c)-14)==b - -b

Note that the && and || operators are logical only, and cannot be used for bitwise comparison. E.g.:

IF a && 16

This will be true as long as a != 0.