Static Commands Usage
Static commands in Jahro refer to commands that are created from static methods. Static methods belong to the class itself rather than an instance of the class. This means they can be called directly from the Jahro console without needing to register a specific object instance.
Creating Static Commands
Creating static commands is as easy as marking a static method with the JahroCommand attribute. Here's an example:
[JahroCommand("PauseGame", "Pauses the game", "game-commands")]
public static void PauseGame()
{
// Your game pausing logic here
}
In this case, "PauseGame" becomes a command that you can call directly from the Jahro console, even without any specific game object.
Static commands can also have parameters. Here's an example of a static command that takes two parameters, a float and a Vector3:
[JahroCommand("player-move", "Move player in direction by distance", "player-commands")]
public static void MovePlayer(Vector3 direction, float distance)
{
// Your player moving logic here
}
In this case, MovePlayer becomes a command that moves a player to a new position when you call it from the Jahro console, using the direction and distance as arguments.
Executing Static Commands
To execute static commands, simply type the command name into the Jahro console. For instance, typing PauseGame in the console will pause the game.
For the MovePlayer command, you would type something like: player-move -1 0 0 7.5, where "7.5" is the distance and "(-1,0,0)" is the direction.
Note: Jahro uses reflection to identify all methods marked with JahroCommandAttribute at the start of your project. By default, all assemblies are searched, but you can specify additional assemblies in Jahro settings. This gives you the freedom to decide which parts of your code Jahro has access to.