Super excited about this new puzzle in Vidar. Should you come across a library, you’ll find books all over the place and all out of order. If you place those books in the right place, something quite awesome will happen. I want to show you how I’m handling the bookcases.
To do this, I used a few variables:
- One for each bookcase – this will hold the item ID of the book currently on the assigned bookcase
- One titled “Book to Place” – this will hold the item ID of the book we’re able to place
- One titled “Bookshelf Being Tested” – when you interact with a bookcase, it places it’s number in this variable
- One titled “Tested Case’s Value” – this looks up what’s current on the shelf you’re interacting with
I also use Yanfly’s Message Manager – a Friday script feature will certainly follow, but I’ve been giving Yanfly a bit too much of the spotlight around here recently 😉 The only use here is to be able to reference an item name easily.
Nearly all of this is handled by a common event. Here it is:
The first line finds out the number stored in the variable associated with that particular bookcase. If the number is greater than 0, it means there’s already something on the bookcase! So, we tell the player that the item is on the bookcase, and ask if they want it. If so, we give it to them, and set the value of the shelf to 0.
If the number’s not greater than 0, we use RPG Maker’s built-in “”Select Key Item” command to allow the player to chose a book from their inventory. That book then gets removed from inventory, and the variable associated with that case is changed to the book’s item ID.
There’s one more step in the equation. The case itself.
This is the event you interact with, and it needs a bit of explaining. The first line is just flavor text. In the second line, we set Bookshelf Being Tested to a number. That number is the variable ID for Case 5.
In every bookcase, we set Bookshelf Being Tested to the correct variable ID. So, if we were testing Bookcase 8, we’d set the variable to 55. What this does is allow our common event to ask “what variable am I supposed to check to see if there’s an item on this particular bookcase?”
We call the common event, and it handles the rest of the logic.