Help understanding variables

Hi again, here with an issue I've been trying to figure but I'm just exhausted. 


So the idea is to have  a room with lets say as an example 10 identical looking events, actionable with action button, from those I want lets say 3 to do something special than the other 7. As an example 10 chests from those 3 have one each a "key".


Now Im not talking here to have a random variable from 1 to 10, that would mean to have a 30% chance to have a "key event" EVERY time I check the chests. So how would you go about just making sure these 3 "keys" are spread around the 10 chests?


The idea is to make the scenes replayable as you dont know where the events are, because it would be too boring to know where are the keys every single time you try it.


Now  there has to be a way to event it out the way I want. Please help me, I just don't know how to figure this logical matter  :headshake:


Do I explain myself?


Thanks in advance!
assign each chest a number, and have three variables for the "key chest numbers".


In the setup event, use control variable to set those three variables to random numbers but reroll if the number is already given (conditional branch, go back to label if second variable is same as first).


Then in each event, compare all three variables with the number assigned to the chest - if it is the correct number give key otherwise something else
Here's a visual for Andar's explanation (make this for every chest event), sorry for using RMMV, but should be the same for XP:


2XOA8Zz.png
Celianna made a typo in the first picture - the second and third control variables both use variable for chest2, the third one of course has to be for chest3


Additionally, the commands in the second picture would result in several times "show text there is no key" if none of the variables are chest 4, so better place the second conditional branch inside the else branch of the first and remove the show text from there. Then place the third condition in the else-branch of the second condition and also remove the show text from there.


Keep the show text only in the last else branch.
Thanks a bunch! you have no idea the hard time my brain was habing with this!!
Woops, forgot to nest the conditional branches! Yes, do place them within the others, otherwise you're gonna get that message 3 times, each time.


Glad you understand it though!

Original thread: https://forums.rpgmakerweb.com/threads/help-understanding-variables.71262/