# Activation Order - Switch/Variable Door Opening Routine

#### gondracorn

##### Villager
I'm perplexed on how a switch would work if you have 4 switches that would have to be activated in a certain order to get the doors/pads/ect  to activate all in the correct way you want them. Otherwise, Only this door will open, and this door will stay closed.

Is there some deep programming for this, or does this require code that I'm not seeing to?

For an instance...

Door #1 can be opened by all for buttons, but depending on which button you press 1st and which buttons you have pressed, door 1 may or may not open. Same rule applys for all other doors. Also, if button A initially opens Door 1, Button B, C, or D CAN re-close that door. Also, if the door was reclosed by button B or C, Button C or D may Reopen that door. In the same case, Button D may close that door once more.

You see, this doesn't seem to be "Button 1 will open Door 1 and Button 2 will close door 1 and open door 2... end of story"

In fact, we're talking about a scenario of 4  buttons, 4 doors, possibly 16 or more scenarios I believe, If my math is correct.

And if order of opening IS relative, perhaps times that by somewhere between 3 and 4?

Last edited by a moderator:

#### Andar

##### Veteran
you'll need a variable to check and record the sequence.

Let's say you have Buttons A, B, C, D and they have to be pressed in exactly that order

Upon entering the map, Variable X is set to Zero.

Now the event for button A checks the Variable when activated. If the variable X == 0 (first press) then it'll increase X by +1 and does whatever should be done on a successfull activation.

If the variable is NOT 0, then the button was pressed out of sequence, sequence is set back to 0 and all doors close (or whatever you want).

Now the event for button B checks the variable for X == 1. If that is correct, the button was pressed in sequence - X+1 and everything as intended. If X is not 1 (either 0 or 2+) then it was pressed out of sequence - reset to Zero etc.

if you want a more complex sequence you might need to use a bit more in variables and switches, that depends on what exactly you want to do.

You can also sequence conditions to have different reactions depending on the current sequence count.

#### gondracorn

##### Villager
you'll need a variable to check and record the sequence.

Let's say you have Buttons A, B, C, D and they have to be pressed in exactly that order

Upon entering the map, Variable X is set to Zero.

Now the event for button A checks the Variable when activated. If the variable X == 0 (first press) then it'll increase X by +1 and does whatever should be done on a successfull activation.

If the variable is NOT 0, then the button was pressed out of sequence, sequence is set back to 0 and all doors close (or whatever you want).

Now the event for button B checks the variable for X == 1. If that is correct, the button was pressed in sequence - X+1 and everything as intended. If X is not 1 (either 0 or 2+) then it was pressed out of sequence - reset to Zero etc.

if you want a more complex sequence you might need to use a bit more in variables and switches, that depends on what exactly you want to do.

You can also sequence conditions to have different reactions depending on the current sequence count.
Yeah,  I was kinda thinking it was a variable addition problem

#### TheRiotInside

##### Extra Ordinaire
Here's maybe a more simple use of variables to get done what you want.

Make the switches do addition and multiplication, then check for a specific amount at the end. For example:

Switch 1: Variable + 2

Switch 2: Variable * 4

Switch 3: Variable + 1

Switch 4: Variable * 2

I haven't tested every combination, but you should be able to check for a specific number which represents a certain switch order. So if you wanted a 1, 2, 3, 4 switch order, your end check would be looking to see if the variable is equal to 18: (((0 + 2) * 4) + 1) * 2 = 18

Something to note is your desired order couldn't do an addition or multiplication twice in a row (as you get 3 by doing 2 + 1 or 1 + 2, you know?). So as long as you alternate your addition and multiplication for the correct order, only one combination should give you that number.

Last edited by a moderator:

### Latest Profile Posts

apparently since its turning 15 years old this year the ps3 is considered "retro". now how old do you feel?
guess that means im an "antique" gamer since ill still play games as old as i am.
"you know your getting old when your childhood console changes ethnicity" lol it turned yellow
I'm making Toilet in Wonderland 2. and tell vinny about it lol
WE ARE THE BORG. YOUR BIOLOGICAL AND TECHNOLOGICAL DISTINCTIVENESS WILL BE ADDED TO OUR OWN. RESISTANCE IS FUTILE.
D2R save files are so broken. how was the beta test better then the full release. blizzard's last hope crashed and burned.
they're getting no more chances from me.