JahroCommand attribute
In Jahro, attributes serve as markers that designate your methods as executable commands within the Jahro console.
How to Use Jahro Attributes
To utilize Jahro attributes, you prepend the method with the [JahroCommand("command-name")] attribute. This works for both static and non-static methods.
Here's a simple example:
[JahroCommand("RestartGame")]
public static void RestartGame()
{
// Your game restarting logic here
}
In this instance, RestartGame becomes a command that you can call from within the Jahro console.
Naming, Describing, and Grouping Commands
Unlike method names in code, command names in Jahro are set explicitly using the [JahroCommand("command-name")] attribute. This provides flexibility in defining more descriptive or simplified command names that can differ from the method names in code.
Additionally, Jahro attributes allow for custom descriptions, and group names. These optional features can be added to the command using the format [JahroCommand("name", "description", "groupname")].
For example:
[JahroCommand("revive-player", "Revives the player with full health", "player-commands")]
public static void RevivePlayer()
{
// Your player reviving logic here
}
In this case, "revive-player" becomes the command name, the description provides additional context when viewing the command, and "player-commands" categorizes this command into a specific group for easier navigation. If no group name is specified, the command defaults to the "Default" group.