HashCommands
public static class HashCommandsNamespace 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.
Properties
Section titled “Properties”Available
Section titled “Available”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.
Methods
Section titled “Methods”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 | |
|---|---|
word | The first token of the line, without arguments. Case does not matter. |
description | One line, lowercase, no trailing period - the way the game words its own. |
example | A 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. |