# 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

It's a Spanish devlog don't get scared!. (please)
Q:"Why don't you get a job?"
A: Posting statuses IS my job. It just so happens to not pay and happen periodically over the course of three months.
My new 49" monitor has been dispatched from the warehouse. Will it arrive tomorrow? The day after? I love that we can track packages now, even if it does only tell me when it's left that end and when it's arrived at the local centre. As long as it doesn't end up in Melbourne again, which has happened before ...
My friend's doing a surprise stream of my game Origin Hunt on Twitch here ! Feel free to stop by