Trying to Make an Item Puzzle

Hey! So, I've been trying to make a specific sort of item-placing puzzle, but unfortunately I haven't been having much luck. I was hoping someone here could show me what I'm doing wrong.

Right now I've got four different key items (books) that the player is supposed to place on four different statues. Then they'd hit a lever that would check if the combination of books/statues they placed is correct; if it is, it'd open a secret passageway.

The contents for each statue currently look more or less like this:
85e6e5c74cabc255e092be30f60c916f.png

Each statue has its own switch called [StatueName]BookPlaced, and the BooksPlaced conditional is supposed to trigger if it detects the correct item number being used (in this case, the book with Item ID #11).

The lever's contents look like this:
d77cf32dbf9b47b7c3f4693b52f522d1.png


Right now, even when I insert the correct combination of books and hit the lever, it says "nothing happened". I'm assuming I'm doing something wrong -- does anyone know what?
You should press F9 and check to see if the variables are all set to what they should be after you do the puzzle. If you see errors there maybe you have setup the variable increases incorrectly.
Hi there!

Nice puzzle! 😀

I didn't manage to get what is wrong with your setup, so I want to help you in another way instead.
Well, there is a looot of ways of doing that. I personally would use javascript for that, but let's make an event.

So the first thing I thought, is that you need to remove the placed books from the player inventory, to avoid place the same book on different statues.

With that, the statues need to have the function for both receive a book from the player and also give it back if the player wants.

For that, instead of using switches to check if a statue has a book, we will need one variable for each statue, that will hold the ID of the placed book.

And also a single variable to get the placed book id from the select key item.

This logic is implemented on the screenshot below:
1632987616636.png


After that step, you can have as many statues as you want. Just make sure that each statue has it's own variable and change that on the first block of script call.

Now, to check if the player put everything on the right order:
1632987912015.png


That is it!
Why not checking all the switches [StatueName]BookPlaced, if they're On then it's working, if no - then not; instead of adding another variable here.
Why not checking all the switches [StatueName]BookPlaced, if they're On then it's working, if no - then not; instead of adding another variable here.
Because the wrong book can be placed on the statue. So he wants you to see that a book has already been placed on the statue with the switch, but the variable tracks how many are the correct book.

I don't see anything wrong in the screens you posted here. So, like Pots said, make sure you're correctly initializing your CorrectBooksPlaced to 0 before you start.

You can also add some basic troubleshooting if you're not good enough with JS to use the console. Add a text window immediately after the player chooses the book that says "BooksPlaced = \V[id]" where the ID is whatever the ID of your variable is. That way you can double check that you're actually placing the correct book.
Hi there!

Nice puzzle! 😀

I didn't manage to get what is wrong with your setup, so I want to help you in another way instead.
Well, there is a looot of ways of doing that. I personally would use javascript for that, but let's make an event.

So the first thing I thought, is that you need to remove the placed books from the player inventory, to avoid place the same book on different statues.

With that, the statues need to have the function for both receive a book from the player and also give it back if the player wants.

For that, instead of using switches to check if a statue has a book, we will need one variable for each statue, that will hold the ID of the placed book.

And also a single variable to get the placed book id from the select key item.

This logic is implemented on the screenshot below:
View attachment 202727

After that step, you can have as many statues as you want. Just make sure that each statue has it's own variable and change that on the first block of script call.

Now, to check if the player put everything on the right order:
View attachment 202728

That is it!
Oh, thanks a ton for the help! I’ll try doing this when I can — will report back if I’ve gotten it to work properly. (I’m still new to working with scripts/variables, so hopefully I won’t get too confused)

I also wasn’t aware I could check variables while playtesting, so thanks for the info!
Because the wrong book can be placed on the statue. So he wants you to see that a book has already been placed on the statue with the switch, but the variable tracks how many are the correct book.

I don't see anything wrong in the screens you posted here. So, like Pots said, make sure you're correctly initializing your CorrectBooksPlaced to 0 before you start.

You can also add some basic troubleshooting if you're not good enough with JS to use the console. Add a text window immediately after the player chooses the book that says "BooksPlaced = \V[id]" where the ID is whatever the ID of your variable is. That way you can double check that you're actually placing the correct book.
Gotcha, that’s a good idea — I’ll try that, too.
Oh, thanks a ton for the help! I’ll try doing this when I can — will report back if I’ve gotten it to work properly. (I’m still new to working with scripts/variables, so hopefully I won’t get too confused)
I think there's nothing wrong with your method, especially if you're not comfortable using JavaScript and you'd just be copy/pasting without knowing what it means. You just need to figure out what's going wrong.

For future reference, you can use the +Quote buttons to quote multiple people in one reply.
So by following @Eliaquim’s code, making sure the variables were properly initialized and checking on things through F9, I managed to get it working perfectly! Huge thanks to everyone who replied!

And gotcha @ATT_Turan, I’ll do that in the future.

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-make-an-item-puzzle.140894/