You may have noticed that when listing useful event commands, we skipped over the buttons for modifying switches, variables, and self switches. That wasn’t an accident. Many of RPG Maker’s features can be used via scripting as well as through an event command, and the former tends to be a lot more versatile, so we go with that.
Manipulating RMXP’s Game Variables
Example: pbSet(1, "hello PC Daily readers") Sets game variable 1 to the value "hello PC Daily readers"
Takes an id (the number of the game variable as an integer), and a value to set the variable to.
Example: pbGet(1) Returns the value of game variable 1.
Takes an id (the number of the game variable as an integer), and returns the value of the corresponding game variable, or nil if the variable is undefined.
$game_switches[id] = value
Example: $game_switches = true Sets game switch 5 to true.
Takes the id (the number of the game switch as an integer) and sets it to the specified true/false value.
Example: $game_switches Returns the value of game switch 5.
Takes an id (the number of the game switch as an integer) and returns the corresponding true/false value.
Setting Self Switches
pbSetSelfSwitch(event, switch, value)
Example: pbSetSelfSwitch(1, "A", true) Sets self switch A of event #1 to true.
Takes the id of an event on the map, the self switch to use (“A”, “B”, “C”, or “D” as strings), and a true/false value.
Press F11 to open the script editor! In here you’ll see the massive list of scripts that make Pokémon Essentials tick. These scripts are written in Ruby Game Scripting System, a version of the Ruby programming language designed specifically for game programming.
Intermediate or advanced knowledge of Ruby is not required to make progress with Pokémon Essentials, but it’s certainly useful and will allow you to customize your game and add features to a far greater extent. At absolute minimum, you’ll need a basic understanding of Ruby (and programming concepts more generally) in order to make any headway, so have a look through the following resources: