• 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!

Legacy GM [SOLVED] Random Passwords? [THX FROSTYCAT]

Calvert

Member
I've just successfully made a system where I can type passwords or [access codes] into my screen to make certain actions happen. Now I want to make the access codes random every time the system restarts.

This is a small fraction of the code:

obj_control Step Event:
Code:
if key0 = "X" && key1 = "C" && key2 = "C"
{
    global.powercode = true;
}

if global.powercode = true
{
    if alarm[0] < 1
    {
        alarm[0]=60
    }
}
If the player types in X - C - C, an alarm goes off and access is granted for whatever that may be.

But this X - C - C is hardcoded in, and I'd like it to be a random 3 digit passcode based off of the variables "Z" "C" and "X".

The bottom half of that code is in another object's step event, but that doesn't matter here. If you need more code, let me know.

How would I go about doing this?
 

FrostyCat

Redemption Seeker
Run this once at the beginning of the game:
Code:
randomize();
global.correct_code[0] = choose("Z", "X", "C");
global.correct_code[1] = choose("Z", "X", "C");
global.correct_code[2] = choose("Z", "X", "C");
Then check against these instead of your hard-coded values.
 

Calvert

Member
Run this once at the beginning of the game:
Code:
randomize();
global.correct_code[0] = choose("Z", "X", "C");
global.correct_code[1] = choose("Z", "X", "C");
global.correct_code[2] = choose("Z", "X", "C");
Then check against these instead of your hard-coded values.
This works perfectly and makes absolute sense. It's so clear that I don't even have any questions about it. Thank you very much FrostyCat.
 
Top