How do I make a code thing

Get help using Construct 2

Post » Sat Sep 06, 2014 1:08 pm

Alright, so let's say i'm making a horror game and you have to enter a code to go through a door.. the code would be "325" if you enter it in order the door opens, if not nothing happens

what i want is how do i control the order of the number, like if i entered "523" nothing happens or so.

i didn't know how to explain this very well but i think you got my point.
B
22
S
6
Posts: 244
Reputation: 2,700

Post » Sat Sep 06, 2014 1:26 pm

This is a way to do it
You do not have the required permissions to view the files attached to this post.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Sat Sep 06, 2014 1:29 pm

Have a text object called dc_xxxxx_input or something you think makes sense for easy code readability. Also make a form button that matches whatever naming scheme you're using but _button at the end. Then use the following Event code:

dc_input_xxxxx_btn -> On clicked

Then add a sub-event of:

dc_xxxxx_input -> Compare text

Set the compare value to be "325".

Then, add the success events you want to happen. Also add an Else for if it fails and you have fail events. If you wanted to keep track of the correct codes, such as if the player can discover the code, it should be in a text instance variable for the dc_input_xxxxx_btn, and instead of doing the dc_xxxxx_input -> Compare text, you want to instead do:

dc_input_xxxxx_btn -> Compare instance variable

Then check if dc_input_xxxxx_btn is equal to dc_xxxxx_input.Text, then have success and fail events.
Founder of Jadelight Studio, Developer of Libertas Aedifex, regular C2 Help contributor and fan of ambient music and Star Wars.
B
12
S
4
Posts: 255
Reputation: 2,008

Post » Sat Sep 06, 2014 1:37 pm

Thank you both, this was easier than i thought :D

Any idea how to do it with sprites or buttons?
B
22
S
6
Posts: 244
Reputation: 2,700

Post » Sat Sep 06, 2014 1:51 pm

Can you be more specific?
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Sat Sep 06, 2014 1:58 pm

Well nvm, i figured it out.. here's the capx it may help anyone..


Password.capx
You do not have the required permissions to view the files attached to this post.
B
22
S
6
Posts: 244
Reputation: 2,700

Post » Sat Sep 06, 2014 3:01 pm

You don't need that spriteFont to clear the textbox all you do is this. I have made change to your work
You do not have the required permissions to view the files attached to this post.
B
256
S
39
G
15
Posts: 1,983
Reputation: 41,036

Post » Sat Sep 06, 2014 3:18 pm

Ok I get what you mean now.

I've upgraded your capx a bit. I've added an OK btn for imputing the password (no need of pressing Enter in the keyboard), and now the system uses only one SpriteFont for the numbered Btns and another one for the ok/clear Btns (you can merge those categories into one universal Btn if you wish).
And, finally, there is a mouse cursor change when ever you are hovering on top of a Btn.
You do not have the required permissions to view the files attached to this post.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Sat Sep 06, 2014 3:23 pm

Cool stuff,thanks guys!
B
22
S
6
Posts: 244
Reputation: 2,700


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo and 32 guests