Show / Hide Table of Contents

Class ModConsole

Allows mods to interact with the in-game console. Output to the console using the Log method and add your own console commands using the RegisterCommand method.

Inheritance
Object
ModConsole
Namespace: Modding
Assembly: Assembly-CSharp.dll
Syntax
public static class ModConsole

Methods

Log(String)

Outputs the given string to the console.

Declaration
public static void Log(string log)
Parameters
Type Name Description
String log

String to output.

Log(String, Object[])

Formats the given string and the given objects like string.Format does and outputs it to the console.

Declaration
public static void Log(string format, params object[] args)
Parameters
Type Name Description
String format

Format string.

Object[] args

Objects to format.

RegisterCommand(String, CommandHandler, String)

Registers a new console command.

Declaration
public static void RegisterCommand(string command, CommandHandler handler, string help)
Parameters
Type Name Description
String command

Name of the command to register.

CommandHandler handler

Function to call when the command is executed.

String help

Help text to display in the help command output.

Remarks

Usually, the command can be executed by the user by entering command, <mod name>:command, or <mod id>:command.

One mod may not attempt to register the same command twice, otherwise an ArgumentException is thrown.

A mod may not register a command that is already implemented in the base game, otherwise an ArgumentException is thrown.

If two or more mods register the same command, only the command syntax including the mod name or id can be used. The user will be pointed to the available variants when attempting to use such an 'overloaded' command.

Similarly, if two or more mods with the same name register the same command, only the syntax including the mod id can be used.

The command name may not contain a colon (':') and the help text may not be empty, otherwise an ArgumentException is thrown.

The handler will be called whenever the command is executed. Its only parameter is a string array containing the arguments passed on the console. Arguments are delimited by spaces. Arguments that should contain spaces can be wrapped in quotes, this is automatically handled by the system and the arguments array will only contain one string for such an argument.

Back to top Generated by DocFX