Two-Way Switches

By Spike14

Here’s what we’re going to do… Create a room, and put all the basics in it. Now put a switch on the North wall, a switch on the South wall, and an electric light on the West wall. Create an Inverter (Fnord>TrapTrig>Inverter) in the center of the room. Leave the East wall blank. Now, open up the light’s properties, delete the “Light” property, and add>Renderer>Anim Light Set the mode to maximum, and fill in the brightness and radius to your liking. Now Add>S>Scripts, and type “AnimLight” (if it isn’t already there). Now, choose one of the switches, and link it to the inverter with a “ControlDevice” link. Now link the other switch to the first switch with a “ControlDevice” link. Now link the first switch back to the second swtich. Now link the Inverter to the light. Calculate lighting, and hit Alt-G to go in-game. Trying flicking one of the switches. The light goes off, and the other switch flicks! Now, let’s dissect this whole thing. The switches start off in the “off” position, which means when they’re first flicked, they send a “TurnOn” signal. Since the light’s already on, this is no good…so we use the Inverter to turn the “TurnOn” into “TurnOff”. The “AnimLight” script on the light makes it so the light will respond to “ControlDevice” on-off signals, and the AnimLight property basically tells the “AnimLight” script what to do. Now, when a switch is linked to another switch, and that switch is flicked…so is the other switch…which is what you saw happen here. That’s why there’s a “ControlDevice” link from Switch 1 to Switch 2, and vice versa, so that if either of them is flicked, so is the other, and if they’re both flicked, a “ControlDevice” signal is bound to be sent to the Inverter, which sends an inverse signal to the light, which switches states! You can use the same thing will doors, only don’t include the inverter… …and remember, have a frobbable Porticullus is fake…set “FrobInfo” to “World Action: Ignore,Script”, then use a switch (or two…or three) to open it! Note: You can add another switch to this system by linking: Switch 2 > ControlDevice > Switch 3 Switch 3 > ControlDevice > Switch 2 …and so on and so forth! If you have any questions, e-mail me at spike14dromed@yahoo.com!


About this entry