Jump to content

Switch Sequence Script Help


Recommended Posts

So I'm having some trouble making a script very similar to the switch sequence in Quake.

So far I have a script where if I press Three switches it opens a door, Here's what it looks like:

int totalswitches = 3;
int switchcount;

script 2 (void)
{
    switchcount++;
    if (switchcount >= totalswitches)
    {
    Door_Open(25, 32, 0);

    }
}

But I'd want to make it when you each switch press a message pops up saying "Three more to go", "Two more to go", And so on

After all Three switches are pressed I want it to finish off with a message saying "A door has opened..."

Thanks!

Edited by HarryDudE

Share this post


Link to post

This is a fizzbuzz problem with multiple solutions, but here's a couple of quick ones:

int totalswitches = 3;
int switchcount;
str switchmessage[3] = { "Two more to go", "One more to go", "The door is now open" };

script 2 (void)
{
    if (switchcount >= totalswitches)
    {
      // Avoid doing out of bounds read if too many switches placed.
      terminate;
    }
  
    print(s:strings[switchcount]);
    switchcount++;
    if (switchcount >= totalswitches)
    {
    	Door_Open(25, 32, 0);
    }
}
int switchcount;

script 2 (void)
{
    switchcount++;
    switch(switchcount)
    {
     case 1:
     Print(s:"Two more to go");
     break;

     case 2:
     Print(s:"One more to go");
     break;

     case 3:
     Print(s:"The door is now open");
     Door_Open(25, 32, 0);
     break; 
    }
}

 

Edited by Edward850

Share this post


Link to post
2 hours ago, Edward850 said:

This is a fizzbuzz problem with multiple solutions, but here's a couple of quick ones:


int totalswitches = 3;
int switchcount;
str switchmessage[3] = { "Two more to go", "One more to go", "The door is now open" };

script 2 (void)
{
    if (switchcount >= totalswitches)
    {
      // Avoid doing out of bounds read if too many switches placed.
      terminate;
    }
  
    print(s:strings[switchcount]);
    switchcount++;
    if (switchcount >= totalswitches)
    {
    	Door_Open(25, 32, 0);
    }
}

int switchcount;

script 2 (void)
{
    switchcount++;
    switch(switchcount)
    {
     case 1:
     Print(s:"Two more to go");
     break;

     case 2:
     Print(s:"One more to go");
     break;

     case 3:
     Print(s:"The door is now open");
     Door_Open(25, 32, 0);
     break; 
    }
}

 

Thank you very much! Got it to work

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
Reply to this topic...

×   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...