Console commands
The WukongMP SDK includes a command console accessible by pressing F1 on your keyboard.
Keyboard shortcutsâ
| Binding | Action |
|---|---|
| TAB | Auto-complete the selected command |
| Alt + â | Previous command |
| Alt + â | Next command |
Defining custom commandsâ
Use the Console API to define custom commands.
Register commands without parametersâ
- Source code
- In-game console
void RebirthAtShrine() { ... }
// ...
{
WukongApi.Console.AddCommand("rebirth_shrine", ConsoleCommand.Create(RebirthAtShrine));
}
rebirth_shrine
Require parametersâ
The command parameters are deducted from the handler signature - supported types are string, int, float, double, and bool.
Parameters can be optional, in which case a default value must be provided.
- Source code
- In-game console
void TeleportToShrine(int shrine = 1001) { ... }
// ...
{
WukongApi.Console.AddCommand("teleport_shrine", ConsoleCommand.Create(TeleportToShrine));
}
teleport_shrine # teleports to shrine 1001
teleport_shrine 2005 # teleports to shrine 2005
Define auto-completed paremetersâ
You can define a list of parameter values that will be displayed when the command is typed in. These values will be selectable with arrow keys and auto-completeable with TAB.
- Source code
- In-game console
IEnumerable<string> GetAllValidUnitNames() => ["wolf_soldier", "wolf_sentinel", "gold_rhino"];
void SpawnMonster(string monsterType) { ... }
// ...
{
WukongApi.Console.AddCommand("spawn", ConsoleCommand.Create(SpawnMonster), GetAllValidUnitNames());
}
Immediately upon finishing the command name, the available parameter values will be shown:
spawn
wolf_soldier
wolf_sentinel
gold_rhino
The parameters are filtered by what's already been typed:
spawn wo
wolf_soldier
wolf_sentinel