Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Genki

How to create a switch sequence?

Recommended Posts

If you have a room with 4 switches and a door, and you want to click them in the right order to open the door, what is the correct script for that? say the layout looks something like this:

----Sw3----Sw4----Dr----Sw1----Sw2----

You start with Sw1,Sw2,Sw3,Sw4.

And if the player clicks wrongly a monster appears in "spot5"
Thanks.

Share this post


Link to post

int seqVar = 1;                                   // global variable (map scope)

SCRIPT 1 (int tryThisNumber) {                    // call this script by each switch, with a first parameter = switch number 1-4
    if(seqVar<5) {                                // door is still closed
        if(tryThisNumber==seqVar) {               // expected number in the sequence == number of the switch which was actually pressed
            seqVar++;                             // next number for next time
            if(seqVar==5) { Door_Open(1,16,0); }  // sequence complete -> open the door
        }
        else {                                    // expected number in the sequence != number of the switch which was actually pressed
            seqVar = 1;                           // start over
            SpawnSpot("DoomImp",5,0,0);           // spawn a monster
        }
    }
}

Share this post


Link to post

Thank you scifista42 :)
I Hope it works, seems a little bit complicated.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×