How do I open door with keypad.

Get help using Construct 2

Post » Mon Sep 14, 2015 10:43 am

hi,

Anybody know how to open a door with keypad. Example would be when a player near a door, a keypad will pop up and the player need to key in at the keypad to unlock the door. Like a security system door.

thanks. :?:
B
9
S
2
Posts: 40
Reputation: 673

Post » Mon Sep 14, 2015 10:46 am

use keyboard plugin
B
12
S
1
Posts: 63
Reputation: 633

Post » Mon Sep 14, 2015 10:52 am

I was planning to use the mouse and click the number at the keypad. It can be open with any single digit, but suppose the number is 12345, any idea how it work?
B
9
S
2
Posts: 40
Reputation: 673

Post » Mon Sep 14, 2015 11:00 am

you could try the following:

you could save the code as text variable keycode="12345" and use a text object for player's key playerkeytextobject=""
when player press a key or click on keypad append the digit to playerkeytextobject then compare the playerkeytextobject with your keycode
Image Image
B
22
S
13
G
135
Posts: 871
Reputation: 70,320

Post » Mon Sep 14, 2015 12:09 pm

can you show me a simple example capx?
B
9
S
2
Posts: 40
Reputation: 673

Post » Mon Sep 14, 2015 1:18 pm

I tested this few month ago
Is it something like this you want to create?
Image Image
B
22
S
13
G
135
Posts: 871
Reputation: 70,320

Post » Mon Sep 14, 2015 2:53 pm

Message: neilgomes can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
MadSpy wrote:I tested https://googledrive.com/host/0B2st_Fvowa86WVlyenBFLVc4ZDg/index.html this few month ago
Is it something like this you want to create?


Yes. Are there any example of this that i can try?
B
9
S
2
Posts: 40
Reputation: 673

Post » Mon Sep 14, 2015 3:04 pm

If by example you mean capx, I don't have the capx with me but I used the following:
* objects: mouse, keyboard, spritefont, function, 3 text objects and 1 other sprite
* each number of numpad pressed or each click on spritefont is append in temptext (invisible) and runs a function to copy the digit and the "_" for digit left while len(temptext) is not egal to max lenght of your key
* once temptext lenght = max lenght, a function compare if temptext= keycode and unlock else display "access denied" and restart the user key
Image Image
B
22
S
13
G
135
Posts: 871
Reputation: 70,320

Post » Tue Sep 15, 2015 4:03 am

Message: neilgomes can only post plain text URLS until they have 500 rep. 2 URLS modified. Why?
Thanks. just found a solution.

Maybe it can be improve.

Capx
https://www.dropbox.com/s/qvlucsrr4rxe1b5/keypad-test.capx?dl=0

Srceen Shot
https://www.dropbox.com/s/j7svdi8tmu995d7/keypad.jpg?dl=0
B
9
S
2
Posts: 40
Reputation: 673

Post » Tue Sep 15, 2015 7:11 am

Take a look: capx

It can be improve (eg attemps left, better trigger with numpad etc)
Image Image
B
22
S
13
G
135
Posts: 871
Reputation: 70,320

Next

Return to How do I....?

Who is online

Users browsing this forum: Mayfly, R0J0hound, tarek2 and 20 guests