Button puzzle?

Get help using Construct 2

Post » Tue Sep 10, 2013 12:08 am

So I'd like to know how to make a button puzzle. for example, you'd have to push certain amount of buttons in a certain order in order for a door to open. How can this be accomplished?
B
10
S
4
G
1
Posts: 159
Reputation: 1,933

Post » Tue Sep 10, 2013 12:28 am

As an example, have an 'Unlocked' variable set to 0, where upon being set to 4 it opens the door. When each button is correctly clicked in a sequence add 1 to 'Unlocked' for each button pressed so that when 4 buttons are pressed in sequence the door will open. If they do not click the correct button in a sequence reset 'Unlocked' to 0 etc.
B
47
S
17
G
81
Posts: 2,224
Reputation: 48,095

Post » Tue Sep 10, 2013 12:48 am

I might need another, detailed example. didn't understand that one you gave me.
B
10
S
4
G
1
Posts: 159
Reputation: 1,933

Post » Tue Sep 10, 2013 9:51 am

Maybe this Pincode example can help you.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Sep 10, 2013 1:49 pm

It won't let me open that one. I have version 139 and that one was saved using a newer version. I can't find newer versions on here though,it only has 139.
B
10
S
4
G
1
Posts: 159
Reputation: 1,933

Post » Tue Sep 10, 2013 1:54 pm

It was made with The latest beta release.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Sep 10, 2013 2:06 pm

Just opened it. the events seem a little too complicated for me to comprehend, i don't understand it at all, lol. Sorry.
B
10
S
4
G
1
Posts: 159
Reputation: 1,933

Post » Tue Sep 10, 2013 2:19 pm

give each button their own unique value stored in the objects instance variable.

buttonA value 1, buttonB value 2 etc.

Then each time a button is pressed add this value to a global text variable.

So it would look like "1,2,1,1," etc depending on the order of clicks.

Have another global text variable with the correct code stored in it to unlock door, then compare the stored text to the code after each click.

If they match the order was correct so open door. If the the number of tokens in the stored text (separated by the comma) is equal or greater then the code text but they dont match then the order was incorrect.
B
43
S
23
G
21
Posts: 735
Reputation: 12,132

Post » Tue Sep 10, 2013 2:45 pm

Heres a really quick example.

I didn't use families for the button as you have the free version.

Demo

capx file
B
43
S
23
G
21
Posts: 735
Reputation: 12,132

Post » Tue Sep 10, 2013 3:34 pm

The code might look a little hard to understand.
What I'm doing is checking the instance variables given to the text object with text.text (which is the text displayed in the textobject)

To set the text I use AnimationFrame because these frames are the same as the numbers displayed, but you could change that to an instance variable if that suits your need better.

The back button was there from an older version and isn't really needed. It removes 1 character from the length of the text and is instructed to do so from the left.

use the limit variable to set the length of the code desired
use the code variable to change the code.

the charactercount variable is used to see how many numbers have been pushed, this could be used for display-purposes.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests