Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → multiple-switch doors
multiple-switch doors
2002-02-04, 5:30 PM #1
Has anyone created a cog for a door that can only be opened by pressing multiple switches simultaneously?
2002-02-06, 10:36 AM #2
I assume you mean pressing switches in sequence since there is no way to press switches simultaneously.

People have made cogs like that for their levels. How many switches need to be pressed to open your door? Do they need to be pressed in a certain order?

------------------
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
2002-02-06, 1:07 PM #3
Yes I did,
So far I have added
two more switches to the cog, increased the linkid. Declared a variable named "Switcher", and incremented it by 1 each time a switch is pressed.
When Switcher is equal to 4, the doors open.
It works, but if you could show me how to make it so that the switches must be pressed in a certain order to do anything, that would be great.
2002-02-07, 2:18 PM #4
That "switcher" variable is a good idea.

Here's one way to have the cog check for switch activation order. Add the following to your cog controlling the door:

Code:
Symbols

surface  switch1  linkid=1
surface  switch2  linkid=1
surface  switch3  linkid=1
surface  switch4  linkid=1
sound soundon=beep1.wav
sound soundoff=beep2.wav
int   switcher=0    local
int   count=0       local
int   switch        local

end

code

activated:
  if (GetSenderID() != 1) return; //message not from switch
  switch = GetSenderRef();
  if (GetWallCel(switch) != 0) return; //switch already on
  setwallcel(switch, 1);
  PlaySoundPos(soundon, SurfaceCenter(switch), 1, -1, -1, 0 );
  count=(count+1);
  if ((switch==switch1) && (switcher==0)) {        //switch1 activated first
     switcher=1;
  } else if ((switch==switch2) && (switcher==1)) { //switch2 activated second
     switcher=2;
  } else if ((switch==switch3) && (switcher==2)) { //switch3 activated third
     switcher=2;
  } else if ((switch==switch4) && (switcher==3)) { //switch4 activated fourth
     switcher=4;
     call opendoors; //or put open door code here
  } else if ((count==4) && (switcher!=4)) { //then reset switches
     sleep(0.5);
     PlaySoundPos(soundoff, SurfaceCenter(switch), 1, -1, -1, 0 );
     setwallcel(switch1, 0);
     setwallcel(switch2, 0);
     setwallcel(switch3, 0);
     setwallcel(switch4, 0);
  }
return; 

end


I've not tested this. Have fun. [http://forums.massassi.net/html/smile.gif]


------------------
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
2002-02-08, 1:35 PM #5
Looks great, I will use it.
I have another question though;
now in the level, you hit the four switches, two doors on the ground slowly open, and then a platform rises from that hole.
I would like to make several gun turrets pop up as well. Is there going to be a problem if I give them two frames and tell the cog to make them go to frame 2?
2002-02-11, 9:25 AM #6
I'm not sure. It should work ok. I would try it and find out. If it doesn't work then I would try modifying the template for the turret and add physics/flags so the turret will move. If the turret is on top of a platform (that you move up) then you don't need to give the turret frames just the platform. To see how to change the template to make something moveable (gravity etc.) then check out the template for the push_crate thing.

------------------
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
2002-02-11, 2:24 PM #7
Isn't there an equivelent one of those cogs in one of the JKSP levels? The pumping station one, if I remember correctly?

------------------
"The future is not determined by a throw of the dice, but is determined by the conscious decisions of you and me."
I am addicted to ellipses!!! AHHH!!! ...

↑ Up to the top!