• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Mac OSX How do I make a door open using a secret code?

Status
Not open for further replies.
E

Enes

Guest
Hello forum! I really eant to realise the idea of finflding an item(secret paper) which states a secret code, e.g xhs5-hdy6-737d. With this code, you can open certain doors, which requirr such codes and then when enter it, it transports the player to another room. PLEASE HELP ME GUYS, I REALLY NEED THIS TO WORK...

PS: I AM NOT THAT GOOD IN CODING SO IF YOU CAN, THEN PLEASE IN DnD, but if not, code is also fine...
 
N

noobhere

Guest
@Enes I'd like to use get_string for that.
It do pause the game and shows a box to fill with string. Then after the box filled, code your own check if the string match or not. Make sure to make it comparable with, the variable that contain the secret code have to be string too.
e.g.
Code:
my_code = "xhs5-hdy6-737d";
code = get_string("Code plz:","");
if(code = my_code)
{
 show_message("Door open!");
}
else
{
 show_message("Wrong code!");
}
 
E

Enes

Guest
@Enes I'd like to use get_string for that.
It do pause the game and shows a box to fill with string. Then after the box filled, code your own check if the string match or not. Make sure to make it comparable with, the variable that contain the secret code have to be string too.
e.g.
Code:
my_code = "xhs5-hdy6-737d";
code = get_string("Code plz:","");
if(code = my_code)
{
 show_message("Door open!");
}
else
{
 show_message("Wrong code!");
}
HONESTLY, THIS IS AWWSOME, MAN! THANK YOU SO MUCH!! BUT A SMALL QUESTION; INSTEAD OF USING ONE ALLOWED CODE (MY CODE), HOW CAN YOU HAVE MULTIPLE ALTERNATIVE CODES THAT WILL ALSO ALLOW IT TO OPEN THE DOOR? LIKE IF YOU HAVE THIS xhs5-hdy6-737d OR 64hd-63djr-irj7, or another code, which I will write, then the door opens. Can you perhaps rewrite the code so that I can see how to put another code? THANK YOU SO MUCH! If this works, I will guve you credit in my game!
 
N

noobhere

Guest
@Enes YOU'RE WELCOME! Well, to put another code simply write it down.
Code:
my_code = "xhs5-hdy6-737d";
my_code1 = "64hd-63djr-irj7"; // add this
code = get_string("Code plz:","");
if(code = my_code or code = my_code1) // add this
{
 show_message("Door open!");
}
else
{
 show_message("Wrong code!");
}
For further, maybe you wanna learn to make it array, which would easy to understand and could make it simpler. It goes like this:
Code:
my_code[0] = "xhs5-hdy6-737d";
my_code[1] = "64hd-63djr-irj7";
Which was the remake from this:
Code:
my_code = "xhs5-hdy6-737d";
my_code1 = "64hd-63djr-irj7";
And thanks if it works then you give me credit!
 
E

Enes

Guest
@Enes YOU'RE WELCOME! Well, to put another code simply write it down.
Code:
my_code = "xhs5-hdy6-737d";
my_code1 = "64hd-63djr-irj7"; // add this
code = get_string("Code plz:","");
if(code = my_code or code = my_code1) // add this
{
 show_message("Door open!");
}
else
{
 show_message("Wrong code!");
}
For further, maybe you wanna learn to make it array, which would easy to understand and could make it simpler. It goes like this:
Code:
my_code[0] = "xhs5-hdy6-737d";
my_code[1] = "64hd-63djr-irj7";
Which was the remake from this:
Code:
my_code = "xhs5-hdy6-737d";
my_code1 = "64hd-63djr-irj7";
And thanks if it works then you give me credit!

THANK U SO MUCH! I will give a try:)
 
C

CptChuckles

Guest
You can further reduce the amount of code by keeping track of how many codes there are and writing a loop
Code:
CodeCount = 5; //there will be 5 elements in the SecretCodes array
SecretCodes[0] = "abc"; //first element of an array is 0, not 1
SecretCodes[1] = "def";
SecretCodes[2] = "ghi";
SecretCodes[3] = "jkl";
SecretCodes[4] = "mno";

UserEntry = get_string("Gimme teh codez!","");

for(var i=0; i < CodeCount; i++) {
  if( UserEntry == SecretCodes[i] ) {
    show_message("Door opens!");
  }
}
You can even have a second array of different rooms to go to
Code:
RoomForCode[0] = room_1;
RoomForCode[1] = room_2;
RoomForCode[2] = room_3;
RoomForCode[3] = room_4;
RoomForCode[4] = room_5;
and then go to it if the code was entered for that room:
Code:
for(var i=0; i < CodeCount; i++) {
  if( UserEntry == SecretCodes[i] ) {
    show_message("Door opens!");
    room_goto(RoomForCode[i]);
  }
}
 
E

Enes

Guest
@Enes YOU'RE WELCOME! Well, to put another code simply write it down.
Code:
my_code = "xhs5-hdy6-737d";
my_code1 = "64hd-63djr-irj7"; // add this
code = get_string("Code plz:","");
if(code = my_code or code = my_code1) // add this
{
 show_message("Door open!");
}
else
{
 show_message("Wrong code!");
}
For further, maybe you wanna learn to make it array, which would easy to understand and could make it simpler. It goes like this:
Code:
my_code[0] = "xhs5-hdy6-737d";
my_code[1] = "64hd-63djr-irj7";
Which was the remake from this:
Code:
my_code = "xhs5-hdy6-737d";
my_code1 = "64hd-63djr-irj7";
And thanks if it works then you give me credit!

Thank you so much!!! I will try that as well and guve you a nice beautiful credit if its work:)
 
E

Enes

Guest
@Enes YOU'RE WELCOME! Well, to put another code simply write it down.
Code:
my_code = "xhs5-hdy6-737d";
my_code1 = "64hd-63djr-irj7"; // add this
code = get_string("Code plz:","");
if(code = my_code or code = my_code1) // add this
{
 show_message("Door open!");
}
else
{
 show_message("Wrong code!");
}
For further, maybe you wanna learn to make it array, which would easy to understand and could make it simpler. It goes like this:
Code:
my_code[0] = "xhs5-hdy6-737d";
my_code[1] = "64hd-63djr-irj7";
Which was the remake from this:
Code:
my_code = "xhs5-hdy6-737d";
my_code1 = "64hd-63djr-irj7";
And thanks if it works then you give me credit!

Hey. I just have a vefy last questiom. Can you maybe rechange the code above so that when the player gives the code, then the written code will be deleted and the player also never have to write again and can do the action whenever possible without entering the code again. Hope you know what I mean, dude...anways, hope you can help me...
 
E

Enes

Guest
You can further reduce the amount of code by keeping track of how many codes there are and writing a loop
Code:
CodeCount = 5; //there will be 5 elements in the SecretCodes array
SecretCodes[0] = "abc"; //first element of an array is 0, not 1
SecretCodes[1] = "def";
SecretCodes[2] = "ghi";
SecretCodes[3] = "jkl";
SecretCodes[4] = "mno";

UserEntry = get_string("Gimme teh codez!","");

for(var i=0; i < CodeCount; i++) {
  if( UserEntry == SecretCodes[i] ) {
    show_message("Door opens!");
  }
}
You can even have a second array of different rooms to go to
Code:
RoomForCode[0] = room_1;
RoomForCode[1] = room_2;
RoomForCode[2] = room_3;
RoomForCode[3] = room_4;
RoomForCode[4] = room_5;
and then go to it if the code was entered for that room:
Code:
for(var i=0; i < CodeCount; i++) {
  if( UserEntry == SecretCodes[i] ) {
    show_message("Door opens!");
    room_goto(RoomForCode[i]);
  }
}

Also you, dude. Can you maybe rechange the code above so that when the player gives the code, then the written code will be deleted and the player also never have to write again and can do the action whenever possible without entering the code again. Hope you know what I mean, dude...anways, hope you can help me...
 
N

noobhere

Guest
@Enes To achieve that, you could create your own variable. Which would determine if the door was locked or unlocked. I'll rechange it:
in the Create Event
Code:
locked = true; // add this
maybe Press <Enter> Event
Code:
if(locked) // add this
{
 my_code = "xhs5-hdy6-737d";
 my_code1 = "64hd-63djr-irj7";
 code = get_string("Code plz:","");
 if(code = my_code or code = my_code1)
 {
  show_message("Door open!");
  locked = false; // add this
 }
 else
 {
  show_message("Wrong code!");
 }
}
else // this also useful
{
 show_message("Door open!");
}
Now, I hope you learn how it goes.
 
E

Enes

Guest
@Enes To achieve that, you could create your own variable. Which would determine if the door was locked or unlocked. I'll rechange it:
in the Create Event
Code:
locked = true; // add this
maybe Press <Enter> Event
Code:
if(locked) // add this
{
 my_code = "xhs5-hdy6-737d";
 my_code1 = "64hd-63djr-irj7";
 code = get_string("Code plz:","");
 if(code = my_code or code = my_code1)
 {
  show_message("Door open!");
  locked = false; // add this
 }
 else
 {
  show_message("Wrong code!");
 }
}
else // this also useful
{
 show_message("Door open!");
}
Now, I hope you learn how it goes.

I see...but how can you actually delete the code so that others cannot use again and is only usable once. After the player wrote the code, there will no get_actions anymore and he can simple open the door without writing the code. Can you perhaps add this in your code? That would be sooooooo amazing, man

P.S: I will definitely give you a credit, for such a wonderful support;-)
 
C

CptChuckles

Guest
At this point you're just asking people to program your game for you. You haven't tried to do anything yourself. And every time someone posts some code to solve one problem, you ask for more. We're not your dev team. Try it yourself and come back when you can show code that you've written that you need help with.
 
E

Enes

Guest
At this point you're just asking people to program your game for you. You haven't tried to do anything yourself. And every time someone posts some code to solve one problem, you ask for more. We're not your dev team. Try it yourself and come back when you can show code that you've written that you need help with.

ehm...is there a law stating this kind of idea? If you want to help me develop a super game, that will soon overpass even Fortnite, then shut your mouth and help me if you can (I am even giving credits for that), but if you don't want to help me, then be quiet and wait till the game is out and you will see in the credit list those people who supported me and will soon get famous too!! #FONLINE
 
E

Enes

Guest

but at this moment, I am trying to break the rules and find trustful members, who are able to help me bring something out, that nobody has even faced before. So, its very simple, either you help me or not

PS: I already knew that someone will search for an eternity to find a rule and bring a ckunter argument. So are you joining or not?

but at this moment, I am trying to break the rules and find trustful members, who are able to help me bring something out, that nobody has even faced before. So, its very simple, either you help me or not

PS: I already knew that someone will search for an eternity to find a rule and bring a ckunter argument. So are you joining or not?
6 Rules of Success:

1. Trust yourself
2. Break some rules
3. Don't be afraid to fail
4. Ignore the naysayers
5. Work like hell
6. Give something back.

- Arold Schwarzenegger
 
Last edited by a moderator:
N

noobhere

Guest
@Enes It's no need to delete any code since your 'locked' variable will prevent it to run again more than once.

OR did you mean to have the door stay opened even you close the game? Well I think you need something about save and load stuff. I guess it's a bit work, I don't really know about it too.

I guess GM has it built in, or not, there must be many other ways. Just search for it, go challenge yourself. Good luck!
 
Last edited by a moderator:
No-one with any actual coding skills would join your team, given your current attitude. Also, this is not a "Team Finding" board. CptChuckles was entirely right, we're not here to code your game for you, but simply to give nudges in the right direction. The original purpose of the post has been answered and therefore there's no more point to bumping this thread.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
No-one with any actual coding skills would join your team, given your current attitude. Also, this is not a "Team Finding" board. CptChuckles was entirely right, we're not here to code your game for you, but simply to give nudges in the right direction. The original purpose of the post has been answered and therefore there's no more point to bumping this thread.
Exactly and this topic is now closed. I would advice @Enes to read the forum rules and STICK TO THEM as it'll go better for them. People around here are incredibly friendly and helpful and we have one of the nicest, kindest communities on the internet in my opinion... but that doesn't mean we'll let people take advantage of our good nature or break the rules. ;)
 
Status
Not open for further replies.
Top