Skip to content

HashCommands

public static class HashCommands

Namespace Hash.Api

Tell the game’s command list about a command your mod answers to itself.

A mod that handles console input with a Harmony prefix on SubmitCommand - the pattern for anything that wants subcommands or arguments the game’s own ConsoleCommand cannot express - registers nothing. Its words run when typed and are invisible everywhere else: the in-game command list, an autocomplete, a help overlay, hash. There is nothing to enumerate, because the words only exist as string literals in a switch.

One call fixes that:

HashCommands.Add("snitch", "profiler: start, stop, top, report", "snitch start");

Listing only. Your prefix keeps running the command exactly as it does now, and the entry this creates never dispatches - a second route would risk running the same line twice.

Reach it through using Hash.Api; and call HashCommands.Add(...). Writing Hash.Api.HashCommands out in full inside a MelonMod does not compile: MelonBase has a string property called Hash, and the member wins over the namespace.

One file, no references, no hard dependency. Compile it into your mod (<Compile Include="path\to\HashCommands.cs" />). Every call is a no-op while hash is absent, and calls made before it loads are replayed once it appears, so load order does not matter.

Example

Declare the words once from the mod’s init, next to the prefix that handles them:

using Hash.Api;
public override void OnInitializeMelon()
{
HashCommands.Add("snitch", "profiler: start, stop, top, report", "snitch top 10");
}
public static bool Available { get; }

True once hash is installed and listening. You rarely need this - Add is safe either way; use it to decide whether to log something to the player instead.

public static void Add(
string word,
string description,
string example = null)

Declare a command word your mod answers to.

The word goes into the game’s own command list, which is what every tool reads - so this reaches the vanilla list and any autocomplete as well, not only hash.

Parameter
wordThe first token of the line, without arguments, e.g. “snitch”. Case does not matter. Spaces around it are trimmed. Null, empty or blank declares nothing. A word that is already declared or already in the game’s command list is not added again.
descriptionOne line, lowercase, no trailing period - the way the game words its own, e.g. “profiler: start, stop, top, report”. Line breaks become spaces. Longer than 200 characters is cut to 197 plus ”…”. Null lists no description.
exampleA line that would work, e.g. snitch top 10. Optional but worth it: hash shows it as the argument shape while the player is typing. Line breaks and length are handled as in description. Null lists no example.