Bookshelf/Random replies

In my game theres a lot of simple events/examining of objects just for fun, like easter eggs or something. For each bookshelf I want the player to interact with it and their character will pull out a random book with some silly name or whatever, from a selection of books on the bookshelf, I would also like to do this with NPCs walking around and have them give 2 or 3 different replies.

How would I do this? What if I want different bookshelves to have different books?
I've been doing this in my game by having the bookshelf call a common event, then in that event have it store a random number in a variable, then that number determines what the shelf will display.

Now, for your case, since you want different shelves to have different books, have the event first call a random number, and store it somewhere (I call mine temp, as I don't need it after the event is done). Then, in the same event, have a conditional branch that does the text for the first book if the random number was say 0, another for if it was 1, and so on.
you can get a random number by using "Control Variables" and using "set" and "Random Number", the rest is as bgillisp said, use a conditional branch compareing the variable you just made. In fact both can use the same variable but use different Conditional Branches, as each time you look at a shelf it will always get a new variable and the variable itself wont effect the text of the books just which text shows up in which shelf.
I was able to figure it out with the help of you both, thank you!  🤘   BD   🤘

Original thread: https://forums.rpgmakerweb.com/threads/bookshelf-random-replies.45692/