Switches for DummiesBehind your map are lots of little people, doing all sorts of jobs that you tell them to do.
Suppose that there are two people in particular: Alexei and Nikolai.
Alexei is holding an apple. Nikolai is holding nothing. At any time, you can tell Alexei to give the apple to Nikolai. Similarly, you can tell Nikolai to give Alexei the apple at any time. Exactly one person must be holding the apple at any one time.
Part of the Gate-keeper's job is to keep an eye on Nikolai. If Nikolai is holding the apple, it is his job to open the gate. He works like this:
| Trigger |
| Description: |
| The Gate-keeper's job |
|
| Conditions: |
| ¤ Nikolai is holding the apple |
| Actions: |
| ¤ Unlock the gate |
If Nikolai isn't holding the apple, then the Gate-keeper won't do anything.
Once Nikolai does have the apple, he will unlock the gate, and then he won't have to do anything else for the rest of the game.
But what will cause Alexei to give Nikolai the apple? You will tell Alexei to give Nikolai the apple when the player gets the key:
| Trigger |
| Description: |
| The player has the key! |
|
| Conditions: |
| ¤ Player gets a key |
| Actions: |
| ¤ Tell Alexei to give Nikolai the apple. |
Now its just as possible for you to tell anyone else in your map to look at Alexei and Nikolai, and to do things according to which one has the apple.
In fact, there are actually 255 different pairs of special people whose job it is to look after a different apple. These pairs of people work just like Alexei and Nikolai do, but they work completely independently of one another.
We call these pairs of people and their apples
switches. If Nikolai has the apple, we say that the switch is 'set'. If Alexei has the apple, the switch is 'cleared'. If we tell Alexei to give the apple to Nikolai, we are setting the switch. All switches are cleared at the beginning of each game.
In this case, the 'real' triggers might work like this:
| Trigger |
| Description: |
| The player has the key! |
|
| Players: |
| ¤ Player 1 |
| Conditions: |
| ¤ Player 1 brings at least 1 men to "Location of the key" |
| Actions: |
| ¤ Set "Switch 1" |
| Trigger |
| Description: |
| Open the gate |
|
| Players: |
| ¤ Player 1 |
| Conditions: |
¤ Player 1 brings at least 1 men to "Location of door"
|
| ¤ "Switch 1" is set |
| Actions: |
| ¤ Disable doodad state for "Left Upper Level Door" for All players at "Location of door" |
"Switch 1" acts as a way of 'remembering' whether you have the key or not.
Actually, there are even more ways we can use switches. At any time, we can call "Bomb!", and whoever is holding the apple will throw it to the other, before realising that what they were holding was actually an apple, not a bomb. If we just want the apple to switch hands between Alexei and Nikolai, regardless of where it is, we call this 'toggling'. When you 'toggle' a switch and it is cleared, then it will be set. If you toggle a switch and it is set, it will be cleared.
The last thing you can do is to grab the apple from whoever has it at any time, and throw it up into the air, so that you don't know whether Alexei or Nikolai will get to it first. Alexei and Nikolai are of the same height and strength, so the chances of either one getting the apple are 50/50 every time. We call this 'randomising' the switch. It randomly puts the switch into one of its two states: set or cleared. It's just like flipping a coin, and is very useful if you want something to be unpredictable.
And that concludes the lesson on switches.
