# Randomizing Input Number Event Command

#### SoundsByDane

##### Villager
I'm creating a puzzle where the player has to find a combination lock number to progress through the game (if they input the wrong number, get a 'wrong number' message). However, if the player knows the combination number ahead of time they skip important parts of the game. So I thought to instead have the combination lock randomize every time the player starts a new game.

I know how to do the randomizing number part. I did a control variable event, then set the variable to a new variable, set the operation to "set", then set the operand to "random" then set that to 1000 ~ 9999 (the Input Number is 4 digits).

I'm not very good at wording my question but I'll try and if It's confusing feel free to ask "What the hell are you talking about?"

How do I have the conditional branch for the combination lock variable set to the random number on each new game?

#### Aerosys

##### Veteran
Yeah that's easy to do

On game start, you set the Variabe "random" the way as you would set a random variable. You told you already know how to do that. Then, when doing a Input Number, you store the result in Variable "input". Eventually, most important, you do a Conditional Branch, with this you can check if Variable "random" IS EQUAL to Variable "input" -> Then your lock is opened.

Game start:
Variable "random" SET random 1 ~ 999

Lock:
Input Number, 4 digits, store in Variable "input"
Conditional Branch, Variable "random" = Variable "input"
open Lock...
Else
Message: Wrong number!

#### ScorchedGround

##### Blizzards most disappointed fan (More than ever)
I did have an idea how to do something like this. Here is what I came up with,
its very primitive though, but it should do the job nonetheless.

First, Randomizing the 4 digit code:
(I hope you can understand this mess, also don't mind the "show text" at the bottom, because that was for testing purposes)

Secondly, Checking if the player puts in the right combination:

EDIT: Oh my god I am incredibly stupid for making it so complicated. I noticed it right after posting this. And because I read @Aerosys suggestion afterwards.

However, my solution will make it more likely to not end up with a code like
"0073", "0009" or "0102 (I think...?)

#### SoundsByDane

##### Villager
Yeah that's easy to do

On game start, you set the Variabe "random" the way as you would set a random variable. You told you already know how to do that. Then, when doing a Input Number, you store the result in Variable "input". Eventually, most important, you do a Conditional Branch, with this you can check if Variable "random" IS EQUAL to Variable "input" -> Then your lock is opened.

Game start:
Variable "random" SET random 1 ~ 999

Lock:
Input Number, 4 digits, store in Variable "input"
Conditional Branch, Variable "random" = Variable "input"
open Lock...
Else
Message: Wrong number!
Yes! The second variable "Input" was what I was missing! Thank you so much!
I did have an idea how to do something like this. Here is what I came up with,
its very primitive though, but it should do the job nonetheless.

First, Randomizing the 4 digit code:
(I hope you can understand this mess, also don't mind the "show text" at the bottom, because that was for testing purposes)

View attachment 175032

Secondly, Checking if the player puts in the right combination:

View attachment 175033

EDIT: Oh my god I am incredibly stupid for making it so complicated. I noticed it right after posting this. And because I read @Aerosys suggestion afterwards.

However, my solution will make it more likely to not end up with a code like
"0073", "0009" or "0102 (I think...?)

Lol no worries! Thank you for trying to help!

### Latest Profile Posts

Surprising nobody, it turns out "next Friday" for the next Jump into Javascript has become "possibly Sunday if you're lucky" XD
Folks, if anyone sends you a message inviting you to add their API to your game, please report them. We don't want people spamming our members asking them to add stuff to their games for their own (or others') benefit. We've updated the forum rules to confirm this.
I'm listening to iiluminaughtii talking about the secrets behind shady businesses and scams. Meanwhile I'm writing a fanfic about Sephiroth from FF7, one specifically for my stepmom. I'll get to give it to her, too, because my boss said I could take the holidays off! Dec. 22-27 I will be in Orlando, and maybe Fort Myers too, visiting my dad and stepmom!
Of course, I bought a handful of games on the Steam Black Friday sale. Will I try them? Will I complete any? Who knows...
I don't really have any neat updates today about how I screwed up programming... But if you want to observe the intensenes of me programming, then you can check out my stream