| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This is an ongoing project, so expect changes. All code is not final and is subject to change. I am currently working on restructuring the repo to contain less git fluff
Commands are assigned by using the Command[...] attribute:
[Command("give", "Gives player an item using ID and Quantity")]
private void GiveCommand(int id, int quantity)
{
...Attributes have many overloads, so you can provide descriptions, hidden commands, certain role access etc (working on improving with extra attributes)
Commands can be assigned in any class, static or instanced (MonoBehaviour)
[Command("give", "Gives player an item using ID and Quantity")]
private static void GiveCommand(int id, int quantity)
{
AddItem(id, quantity);
}private void Awake()
{
// Called Only Once
CommandRegistry.RegisterInstanceCommands(this);
}
[Command("give", "Gives player an item using ID and Quantity")]
private static void GiveCommand(int id, int quantity)
{
AddItem(id, quantity);
}To execute commands, you simply pass the raw inputted string (eg "give 192 1") to the CommandExecuter class. The CommandExecuter class automatically converts the string into 2 parts: The command name, and the arguments
It achieves this by converting the split string into each parameter Data Type. You can take a look inside CommandParser.cs for how it works.
// userInput = "give 192 1"
private void OnInputSubmitted(string userInput)
{
CommandExecutor.ExecuteCommand(userInput);
// Returns success - player recieves 1x of item ID 192
}If the command is successful, a log will be created. Otherwise, a warning will appear notifying the user that the command was incorrect.
| Back | FazBrowse Home | New Git URL |