Smartest way to do this?

BigDaveBigDave Posts: 2,129
edited March 2 in Working with GS (Mac)

for a memory mini game I want to create random sequences which the player has to re-created with his 4 buttons

Button 1,2,3,4

And a randomly created sequence could look like this


So i wonder whats the smartest way to create that.
Checking if the play does use the buttons in the correct order.


  • Braydon_SFXBraydon_SFX Dallas, TexasPosts: 8,788

    Not sure I understand correctly, but I'll try and answer anyway. What you could do is hold the answer in a table, and write the button integer values to a separate table as the player pressed the button. Afterwards, you can use the Table Merge function and then compare the results. If they're the same, then they entered the correct sequence. If not, then they didn't.

  • Braydon_SFXBraydon_SFX Dallas, TexasPosts: 8,788

    You could obviously do this all in one table, but for clarity I said you could separate it. :)

  • BigDaveBigDave Posts: 2,129

    But i would need seperate variables for each right?

    Seqeunce number 1 = 2
    Seqeunce number 2 = 1
    Seqeunce number 1 = 2

    is it possible to have the squence directly as one string



    so random function would role x times and connect each result as one string.

    I guess im basically searching for something like "text" +"text"

    (i also just came up while writing this that I could do 21243 by /1 /10/100/1000/10000)

    do I still have a question know?
    i dont know

  • BigDaveBigDave Posts: 2,129

    Thanks guys I should find a soluation now

  • tatiangtatiang Posts: 10,722

    Just concatenate the inputs onto a blank text string (attribute) and check that string against the correct answer. So for each button press, the string changes:


    You can check after each input or just at the end (e.g. when textLength(game.input)=textLength(game.answer)).

  • tatiangtatiang Posts: 10,722

    If your question is how to concatenate (join) the text strings, you would do it like this assuming your button actor has a self.value attribute set to 1, 2, 3, or 4:

    When touch is pressed
         Change Attribute game.input to game.input..self.value

Sign In or Register to comment.