#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Smartest way to do this?

Posts: 2,239Member
edited March 2017

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

2,1,2,4,3

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

• Posts: 9,008Member, Sous Chef, PRO, Bowlboy Sidekick

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.

• Posts: 9,008Member, Sous Chef, PRO, Bowlboy Sidekick

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

• Posts: 2,769Member, PRO
• Posts: 2,239Member

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

like

2+1+2+4+3
21243

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

• Posts: 2,239Member

Thanks guys I should find a soluation now

• Posts: 11,297Member, Sous Chef, PRO, Senior Sous-Chef

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:

[blank]
2
21
212
2124
21243

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

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Posts: 11,297Member, Sous Chef, PRO, Senior Sous-Chef

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

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User