Jump to content
  • 0

How to make switch which requires 2 keys to activate


Skunkbear

Question

Hello All,

 

So I'm trying to make a switch which requires both the red and blue key (script at the bottom) to activate, however, if I have the switch set to activate once, then when I try and use it without the keys it prints the message, plays a noise, changes texture, and then can't be interacted with again. If I have it set to repeatable, then the floors and ceilings keep moving on repeated presses which I don't want either.

 

Is there a simple way to change the code below to make it so that the switch doesn't activate at all until both keys are obtained (apart from printing the message)? I've tried a few different variations such as reversing the script so that the actual actions happen in the 'else' statement, or trying to terminate the script once the switch has successfully been used but nothing seems to be working. Thanks in advance.

 

script 12 (void)
{
    if (CheckInventory("RedCard") && CheckInventory("BlueCard"))
    {
        Floor_LowerByValue(57,16,128);
        Ceiling_RaiseByValue(58,16,128);
    }
    else
        Print(s:"You need both the red and blue keys.");
}

Share this post


Link to post

4 answers to this question

Recommended Posts

  • 2

ClearLineSpecial will disable the linedef from doing anything. You add it into your success condition, i.e. when the player has the red and blue cards and uses the switch.

 

You can also make a global variable, check if it's set before running the script, and set it when the script runs. See this thread (but make sure to read all the replies):

https://www.doomworld.com/forum/topic/94582-using-acs-check-if-script-has-run-already/

 

There are probably other ways too, it should be fine to use whatever you find easiest.

Edited by plums

Share this post


Link to post
  • 0

A potential solution to the problem would be to add a Blue Key obstacle, and a Red Key obstacle in front of the switch.

 

To activate the switch past the Blue Key obstacle, and Red Key obstacle, you will have to clear the obstacles first (Red Key Gate in DOOM2 MAP02).

Share this post


Link to post
  • 0
19 hours ago, plums said:

ClearLineSpecial will disable the linedef from doing anything. You add it into your success condition, i.e. when the player has the red and blue cards and uses the switch.

 

You can also make a global variable, check if it's set before running the script, and set it when the script runs. See this thread (but make sure to read all the replies):

https://www.doomworld.com/forum/topic/94582-using-acs-check-if-script-has-run-already/

 

There are probably other ways too, it should be fine to use whatever you find easiest.

The ClearLineSpecial worked like a charm. Thanks everyone!

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...