Bookshelves – Dev Blog

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:

Ignore the stuff below, it's just there to handle what happens when you try to put your journal on the bookcase. It doesn't belong there!

Well, almost all of it. Ignore the stuff below the cut-off, it’s just there to handle what happens when you try to put your journal on the bookcase. It doesn’t belong there!

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 actual event the player interacts with. Put it on the bookcase!

This is the actual event the player interacts with. Put it on the bookcase!

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.

 

As noted at the top, every case gets its own variable.

As noted at the top, every case gets its own variable.

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.

 

Advertisements

2 thoughts on “Bookshelves – Dev Blog

  1. Pingback: Music Puzzle | The Iron Shoe
  2. Pingback: Friday Script – Plugging Into Yanfly’s Message System | The Iron Shoe

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s