Randomizing Input Number Event Command

SoundsByDane

Villager
Member
Joined
Mar 17, 2020
Messages
21
Reaction score
8
First Language
English
Primarily Uses
RMMV
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
Veteran
Joined
Apr 23, 2019
Messages
589
Reaction score
567
First Language
german
Primarily Uses
RMMZ
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)
Veteran
Joined
Apr 12, 2020
Messages
644
Reaction score
888
First Language
German
Primarily Uses
RMMV
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)


code.png

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

code2.png

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
Member
Joined
Mar 17, 2020
Messages
21
Reaction score
8
First Language
English
Primarily Uses
RMMV
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 Threads

Latest Posts

Latest Profile Posts

Enemies deserve some spotlight also
hackingCompressed.gif
I think I can make a text-based mini-game with almost zero art assets and with code only...just a lot of code as assets all by themselves. :kaojoy:
A video update on the progress I've been making on the cutscenes. :kaosalute:

I wonder if color LUTs is possible for RPG Maker. It would be game changer and can replace the not so good looking tint screen
new mechanic in battle where you can mentally erase enemies when you deplete all their MP instead HP. this gives you a special item of their "memory". it's pretty to do in battle so far.

Forum statistics

Threads
115,866
Messages
1,093,576
Members
151,090
Latest member
irina35
Top