I am trying to create a puzzle in rpgmaker vx ace similar to the famous "Lights Out" puzzle.
If you are unfamiliar, Lights Out is a game where you are given a grid of lights that you can turn on and off. The object of the game is to completely turn off all lights in the grid. The catch, however, is that if you toggle a light, every adjacent (top,bottom,left,right) light to the one you toggled will toggle as well, so it makes it tricky to find a way to turn every light off without accidentally turning on another one. You can try it out for yourself and see how it works here:
http://www.logicgamesonline.com/lightsout/
My idea for how this should be approached is by creating an event, that when activated, will call a common event while at the same time switching to another event page with a different graphic.
Each event would have its own private variable to determine its graphic.
The part that I need help with is the common event's first action, which would be to check every adjacent tile to the one clicked, and if its variable is >0, then subtract 1. If its variable is <1, then add 1. This can probably be done with event commands that would take up a huge amount of lines, but I feel like a script for this would be at most 7 lines. I'm not sure.
Can somebody help create a script that would do this? Is this method even convenient? If so, how would you go about creating a puzzle like this?
EDIT: Do not worry about the player not being able to reach tiles in the middle of the puzzle, for I am using a mouse system script in my game. Because of this, I would appreciate it if you didn't utilize the player's XY position on the map in the script.