How do I require something to be done in a specific sequence?

0 favourites
  • 8 posts
  • If I have 5 different light switches:

    1 2 3 4 5

    But the player needs to turn them on in the following order to get the door to unlock:

    2 3 5 1 4

    How do I 1) make the switches wait until the entire sequence is done incorrectly to reset (instead of just resetting after getting the first one wrong) and 2) setting the door to only unlock if the player gets that sequence right?

    Does my question make sense?

    Thanks in advance?

  • The simplest method would be to use a string variable.

    Each input set the variable to the current value and the new input.

    On input variableString set value to variableString& input

    You would also need a counter to tell it when to check.

    When it's time to check, compare varaibleString to another variable with the correct order.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The simplest method would be to use a string variable.

    Each input set the variable to the current value and the new input.

    On input variableString set value to variableString& input

    You would also need a counter to tell it when to check.

    When it's time to check, compare varaibleString to another variable with the correct order.

    Newt has the solution with one suggestion. An array.

    As they turn the switches on, build a string of switch numbers. When the last one has been turned on, compare that to a string in an array. This way, you can have as many sequences as you wish.

  • Thank you both for the suggestions. I think this is where my limited knowledge really fails me. I don't fully understand what newt is saying, and as for your suggestion, Fengist, I've looked up every tutorial there is (written and video) and my brain just cannot understand arrays. I'll keep plugging at it with Newt's suggestion though and see if I can stumble into getting it right. Thanks again to both of you!!!

  • A very basic example

    dropbox.com/s/06ag97z673lruax/orderstring.c3p

  • A very basic example

    https://www.dropbox.com/s/06ag97z673lruax/orderstring.c3p?dl=1

    Oh my gosh, that makes it so simple!!! Thank you so much newt !!!! That's amazing!

  • And here's newt 's example modified to use an array of 5 possible switch combinations.

    https://www.twistedvoid.com/c3examples/ArraySwitches.c3p

    Take note of the added file "SwitchList.json"

  • Fengist Thank you!!!!

    I swear I have no idea what I'd do without this forum

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)