You can use many different tools to manage your conditions, here's a list:
Effects Code
IF EQUAL TO ==
IF BIGGER THAN >
IF SMALLER THAN <
IF SMALLER OR EQUAL THAN <=
IF BIGGER OR EQUAL THAN >=
IF NOT EQUAL TO !=
AND &&
OR ||
SET VALUE EQUAL TO =
ADDITION +=
SUBTRACTION -=
MULTIPLICATION *=
DIVISION /=
MODULUS %=
EXPONENTIATION **
(1.1.1) If Expressions :
If Expression Syntax:
if component == condition
actions
elsif component == condition
actions
else
actions
end
If Expression Example:
if $game_switches[1] == true
$game_variables[1] = 1
elsif $game_switches[2] == true
$game_variables[2] = 1
else
$game_switches[3] = true
end
The if Expression evaluate (verify, check) the component's content against the condition, the if Expression becomes "True" when the condition is met. When the Expression is "True", the actions listed below the first if Expression is processed. If the Expression return "False" (The conditions aren't met), the if Expression jumps to the next Else (elsif/Else) line in the code, and evaluate it again. The if Expression will end when the keyword "END" is met.
(1.1.2) Case Expressions :
Case Expression Syntax:
case component
when 0 .. 2
actions
when 3 .. 6
actions
Else
actions
End
Case Expression Example:
case $gold
when 0 .. 50
$game_variables[1] = "Poor"
when 51 .. 100
$game_variables[1] = "Rich"
Else
$game_variables[1] = "Ultra Rich "
End
The case Expression evaluate (verify, check) the component's content against the condition, the case Expression becomes "True" when the condition is met. When the Expression is "True", the actions listed below the first when Expression is processed. If the Expression return "False" (The conditions aren't met), the case Expression jumps to the next When (or else) line in the code, and evaluate it again. The case Expression will end when the keyword "END" is met.
The line "when 0 .. 50" tells the system to check if the component's value are between 0 and 50 included. Meaning that the condition will be true if the value of the variable $gold (from our example) is between 0 and 50, including 50.
(1.1.3) Unless Expressions :
Unless Expression Syntax:
unless component == condition
actions
Else
actions
End
Unless Expression Example:
unless $gold == 10
$game_switches[1] = false
Else
$game_switches[1] = true
End
The unless Expression evaluate (verify, check) the component's content against the condition, the unless Expression becomes "True" when the condition isn't met. When the Expression is "True", the actions listed below the first unless Expression is processed. If the Expression return "False" (The conditions are met), the Expression jumps to the else line in the code, and process it. The unless Expression will end when the keyword "END" is met.
Meaning that when the variable $gold (from our example) equals 10, the $game_switches[1] = true action will be processed and that switch will be ON. Otherwise, the $game_switches[1] = false action will be processed and that switch will be OFF.
(1.1.4) While Statement (Loop) :
While Statement Syntax:
while component == condition
actions
End
While Statement Example:
while $gold == 10
$game_switches[1] = true
End
The while Statement evaluate (verify, check) the component's content against the condition, the while Statement becomes "True" when the condition is met. When the Statement is "True", the actions listed below the while Statement is processed. Those actions will be processed as long as the condition is true, meaning that the game may freeze if there isn't another Event that may modify the state of the component's value; because the actions will always be processing.
If the variable $gold equals 10, the Statement is true, therefore the actions $game_switches[1] = true will be processed for as long as $gold equals 10. If $gold doesn't change, the game will be stuck in the while Statement. Using this kind of code in a Call Script may freeze your game, because this is a "loop" statement.
(1.1.5) Until Statement (Loop) :
Until Statement Syntax:
until component == condition
actions
End
Until Statement Example:
until $gold == 10
$game_switches[1] = true
End
The until Statement evaluate (verify, check) the component's content against the condition, the until Statement will process the actions for as long as the component's value do not meet the condition.
Meaning that until our variable $gold equals 10, the action $game_switches[1] = true is processed. Using this kind of code in a Call Script may freeze your game, because this is a "loop" statement.
(1.2) For Loop :
For Loop Syntax A:
for i in start..end
actions
end
A For Loop will execute it's body (actions) until it reaches the end value. The For Loop actually "iterate" the actions found in its body and store the numbers of iteration in the variable i. We can use any numbers or string (text) as start and end value. This will create the For Loop range. A range is defined using points (..) or (...). Using two points, as in the example above will make a range starting from the start value and ending at the end value, including the end value. Using 3 points (...) will exclude the end value. See the example below.
For Loop Syntax Example A1:
for i in 0..10
print i
end
*Will print on screen the following result, each one in a new window:
0
1
2
3
4
5
6
7
8
9
10
For Loop Syntax Example A2:
for i in 0...10
print i
end
*Will print on screen the following result, each one in a new window:
0
1
2
3
4
5
6
7
8
9
For Loop Syntax Example A3:
for i in "a".."e"
print i
end
*Will print on screen the following result, each one in a new window:
a
b
c
d
e
For Loop Syntax B:
for i in [value1, value2, value3, etc]
actions
end
This syntax works as the other one shown above, but we specifically tells the for loop what i will be equals to in each iteration (loop). Look at the following sample, and remember that once again, string and integers (text and numbers) can be used.
For Loop Syntax Example B:
for i in [1, 5, "c", 20]
print i
end
*Will print on screen the following result, each one in a new window:
1
5
c
20