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

Ask about mapping, UDMF, using DoomBuilder/editor of choice, etc, here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Post Reply
Visceral_Nightmare
Posts: 21
Joined: Sat Feb 08, 2020 8:49 am

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

Post by Visceral_Nightmare »

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.
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

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

Post by Enjay »

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.
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

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

Post by Caligari87 »

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: Select all

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-)
Visceral_Nightmare
Posts: 21
Joined: Sat Feb 08, 2020 8:49 am

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

Post by Visceral_Nightmare »

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!
Post Reply

Return to “Mapping”