Debug Commands
NOTE
This page assumes you have a HarmonyX project setup for R.E.P.O. modding.
If not, first follow the guide in HarmonyX Project Setup.
The Debug console is a vanilla feature added in v0.3.0
Debug commands can be executed in the debug console, chat, or both depending on how you register your command.
Chat Commands
Typing a chat command in chat requires you to start with a /
Debug Console
INFO
You must enable Developer Mode in the REPOLib config settings and restart the game to access the debug console.
Debug console commands can be executed at any time, including in the main menu and lobby menu.
Open the debug console by pressing the tilde (~) key. For non-US keyboard layouts, this is typically the key directly below ESC and to the left of 1.
Tips:
- Typing a command in the debug console does not require a
/. - You can scroll through previous entries with the up/down arrow keys or the scroll wheel.
- When a suggestion is selected, press TAB to auto-complete it.
- You can use middle mouse click to repeat the previous command.
- Items and valuables spawn at the nearest level point, while enemies spawn in a nearby room.
Registering Debug Commands
Registering a debug command:
using BepInEx;
using System.Collections.Generic;
[BepInPlugin("You.YourMod", "YourMod", "1.0.0")]
[BepInDependency(REPOLib.MyPluginInfo.PLUGIN_GUID)]
public class YourMod : BaseUnityPlugin
{
private void Awake()
{
// Call your command's register method from your plugin's awake.
MyCommand.Register();
}
}
// Create a static class for your command logic.
public static class MyCommand
{
public static void Register()
{
var cmd = new DebugCommandHandler.ChatCommand(
// The name of your command.
// This is what the user will type to execute it.
// The name should not include spaces.
"test",
// The description of your command.
"This is my test command",
// The execute function of your command.
Execute,
// This argument is optional.
// This provides additional command argument suggestions as the user types.
// The user must type the full command name and a space before suggestions appear.
Suggest,
// This argument is optional and true by default.
// Function to determine if the command should be enabled.
IsEnabled,
// This argument is optional and true by default.
// If true, the command will only be accessible in the debug console.
debugOnly: false
);
REPOLib.Modules.Commands.RegisterCommand(cmd);
}
// isDebugConsole will be true if the command is executed from the debug console.
// args are additional options passed to your command.
private static void Execute(bool isDebugConsole, string[] args)
{
// Call this function if your command executes successfully.
DebugCommandHandler.instance?.CommandSuccessEffect();
// Call this function if your command execution fails.
DebugCommandHandler.instance?.CommandFailedEffect();
}
// The Suggest function only runs while typing in the debug console.
// You must type the command name and a space first.
// Every character added or removed runs the Suggest function again.
// isDebugConsole will be true if the command is executed from the debug console.
// partial is the latest argument string from args.
// args is the full list of arguments.
private static List<string> Suggest(bool isDebugConsole, string partial, string[] args)
{
// Return a list of possible arguments based on the current partial and args.
return [];
}
private static bool IsEnabled()
{
// Add logic here if you want your command to be conditionally enabled.
// Disables your command in the main menu.
if (SemiFunc.IsSplashScreen() || SemiFunc.IsMainMenu())
{
return false;
}
// Disables your command in the lobby menu.
if (SemiFunc.RunIsLobbyMenu())
{
return false;
}
// Disables your command in the tutorial.
if (SemiFunc.RunIsTutorial())
{
return false;
}
// Disables your command if you are not the host.
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return false;
}
return true;
}
}