2 switches to do one thing, but I on;y need one

Tue Oct 26, 2021 8:42 am

Confusing title but I can't seem to find a tutorial about this at all, but I have two switches who do the same thing, to the same sectors which is lower stairs, but I only need one to ever be used, how do I deactivate or hide the one I don't need after its been used? I'm assuming acs but I'm honestly not sure. any help would be much appreciated.

Re: 2 switches to do one thing, but I on;y need one

Tue Oct 26, 2021 9:00 am

Yes, ACS would be the way to do it.

There are two methods.
The more programmer-like one is to define a variable in your script and check it before the script does anything else. The first time the script gets run, it sets the variable to a value and then lowers the stairs. If the script gets run again, this time it check the variable and, because it has already been changed, it skips the instructions to lower the stairs.

The more mechanical version is to give both lines that run the script a line tag and when the script is run, the script clears the special from the switches and then lowers the steps. If you try to use either switch again, it will do nothing because its special has been removed.

In such a simple case, to my mind, the second one has a couple of advantages. It would be a simpler script and because the switches have had their special removed, they would not change appearance when you use them. With the first solution, the switches would still change because although the script is apparently doing nothing, it is still getting run.

Of course, if you wanted to get a bit fancy, then you could use the first method and if the script has been run once instead of just doing nothing on subsequent uses of the script, you could set it to print a message saying something like "the stairs have already been lowered".

If you are not sure how to do the above, let me know which version you fancy and I can post an example.

Re: 2 switches to do one thing, but I on;y need one

Tue Oct 26, 2021 9:26 am

Adding on to the above, there's a more "analog" solution that may help players not get confused as well. Since both switches run the same script, and scripts can perform more than one action, have that script also raise or lower a wall in front of both switches on activation. This will hide the switches from the player, both blocking future activation and visually indicating that neither switch can be used again. Also would save having too assign a line ID to each switch line for clearing the switch special.

EXAMPLE:
Code:
Script 1 (void) {
    Stairs_BuildDownDoom(<tag>, <speed>, <height>, <delay>, <reset>); // Or whatever special is used to lower your stairs
    Ceiling_LowerToFloor(<tag>, <speed>); // Lower a ceiling panel in front of switch 1
    Ceiling_LowerToFloor(<tag>, <speed>);  // Lower a ceiling panel in front of switch 2
}


8-)

Re: 2 switches to do one thing, but I on;y need one

Tue Oct 26, 2021 10:06 am

Thank you! I thought there was a vanilla doom way too take care of this, where I swore I'd seen two switches that did the same thing and they just stopped working after one was used, but clearly I've dreamt it! Anyway thanks a million!