Debug mode

This page describes the **Debug mode** available in Essentials.

## What is Debug mode?

Debugging refers to playing a game with the aim of making sure everything works properly in it, and finding and fixing any problems that may arise before the game is made publicly available.

To help with this, games will often have a Debug mode, which is a mode only accessible to the game's developers. This mode provides additional commands and options that allow the developers to play through the game more easily and see what is going on behind the scenes. These commands can include the ability to modify Pokémon stats, warp to maps, and change game variables.

Essentials has a Debug mode.

### Enabling Debug mode

A game run from RPG Maker XP (rather than run by itself) is automatically in Debug mode. The Debug mode can be also toggled on and off by setting the variable `$DEBUG` to `true` or `false` respectively.

## Gameplay changes in Debug mode

Debug mode changes a number of features in the game, and enables several more options. These changes are:

* A console window is opened alongside the game's window. You can print messages to the console with `echoln "message"` lines of code in the scripts to help you monitor various aspects of the scripts in use.
* Upon starting the game, it may compile plugin scripts and data in the PBS files if the game detects they have been updated. You can hold Ctrl while the game starts to force these to compile (or hold Shift to force just the plugin scripts to compile) - the game's window must be in focus to do this, not the console window.
* The splash and title screens are skipped, and the Continue/New Game screen is shown straight away.
	+ The Continue/New Game screen contains a "Debug" option which opens a limited form of the Debug menu described below.
* The Pause menu contains an extra option: "Debug". This opens the main Debug menu. See below for details.
	+ This Debug menu can also be accessed by pressing F9.
* There is a Debug menu in battle, accessed by pressing F9 while in the main choice menu (Fight/Bag/Pokémon/Run).
* In the Party screen and the Pokémon storage screen, the interact menu for Pokémon/eggs contains an extra option: "Debug". This opens a menu with debugging commands that apply to that Pokémon. See below for details.
* In the Bag, the interact menu for items contains an extra option: "Make Mystery Gift". This lets the player create a Mystery Gift containing that item.
* The player can throw away important items such as Key Items and HMs from the Bag.
* The player can use any field moves at any time, even without the required Badge.
	+ If the field move can be used by interacting with something in the overworld (e.g. a small tree for Cut, water for Surf), then the player can use that move even if none of their Pokémon knows it.
	+ Field moves that can only be used by selecting it from a Pokémon's menu in the Party screen (e.g. Teleport, Sweet Scent) still need to be known by a Pokémon in order to select it in the first place. Gym Badge requirements are ignored for these, though.

There are many more features of Debug mode, all of which require the Ctrl key to be pressed or held (this allows normal functionality to be experienced by not holding it). These features include:

* Hold Ctrl when closing an error message to copy that message to the computer's clipboard.
* Hold Ctrl while starting the game in Debug mode to force the game to recompile plugin scripts and PBS files.
* In the overworld, hold Ctrl while moving to move over any tile.
* In the overworld, hold Ctrl to skip trainer battles and prevent wild encounters from occurring.
* In the overworld, hold Ctrl while using the Poké Radar to be able to use it regardless of its battery level.
* When using Fly, hold Ctrl to allow flying to a location that hasn't been visited yet.
* In the mining mini-game, hold Ctrl while breaking the wall to prevent the crack from getting longer.
* In battle, hold Ctrl after a move's animation plays to force its additional effect to occur (if it has one).
* In battle, hold Ctrl at the start of throwing a Poké Ball to ensure that it will capture the Pokémon.
* In battle, hold Ctrl when choosing "Run" to ensure fleeing is successful. You can even run from trainer battles this way, and will be given the choice of whether to treat it as a win or loss for the player.
* In battle, hold Ctrl while opening the Fight menu to force the Mega Evolution option to appear (ignoring whether you have already performed a Mega Evolution this battle, and ignoring whether you have a Mega Ring item).

## Debug menu

The Debug menu contains functions useful for debugging or configuring a Pokémon game. You can access it from the Continue/New Game screen, the Pause menu or by pressing F9 in the overworld.

The Debug menu has two levels of options. An option with "`...`" at the end of its name opens a sub-menu. Debug functions are grouped together for easier navigation.

The Debug menu functions are as follows:

When accessed from the Continue/New Game screen, only the "PBS file editors...", "Other editors..." and "Files options..." sub-menus are accessible. This is because the other sub-menus relate to in-game information which doesn't exist yet (because a save file has not been started or loaded).

## Pokémon Debug menu

The Pokémon Debug menu is accessible from the party screen, the Pokémon storage screen and the Debug menu function "Test Wild Battle Advanced" (see above). It contains options that edit aspects of the chosen Pokémon.

Most of the functions are self-explanatory, and often display information related to the selected function (e.g. the Pokémon's Hidden Power when "Set IVs" is selected).

An function with "`...`" at the end of its name opens a sub-menu with more function in it.

The function in the Pokémon Debug menu are as follows:

## Battle Debug menu

The battle Debug menu allows you to change many aspects of a battle, including the Pokémon and trainers participating in it, the environment/weather/etc., and the special effects that apply. You can also view the speed order of Pokémon in battle. You can access it by pressing F9 in the main battle menu (the one in which you choose between Fight/Bag/Pokémon/Run).