VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public Member Functions | Private Attributes | List of all members
AVR.Core.Attributes.ConsoleCommand Class Reference

This attribute can be used to easily make a function into a command runnable through the AVR_DevConsole. This can only be used on static void-functions where the parameters are eithe none, a single string or an array of strings. Usage examples: More...

Inheritance diagram for AVR.Core.Attributes.ConsoleCommand:

Public Member Functions

 ConsoleCommand (string command_string, int min_args=0, string description="No description given.")
 Defines a method as a command vor the AVR_DevConsole.

Parameters
command_stringString which represents the command. This is the same string a user inputs to run it.
min_argsMinimum amount of arguments a user must provide for the command to run.
descBrief description that explains what the command does and how it is used.
More...
 
 ConsoleCommand (string command_string, string description)
 Defines a method as a command vor the AVR_DevConsole.

Parameters
command_stringString which represents the command. This is the same string a user inputs to run it.
descBrief description that explains what the command does and how it is used.
More...
 
string getCommandString ()
 
int getMinArgs ()
 
string getDescription ()
 

Private Attributes

string command_string
 
string desc
 
int min_args
 

Detailed Description

This attribute can be used to easily make a function into a command runnable through the AVR_DevConsole. This can only be used on static void-functions where the parameters are eithe none, a single string or an array of strings. Usage examples:

This will add "run_command" as a command that outputs a hello world message. The second parameter in the constructor provides a description, which the user can see by using the "help" command. Providing a description is not mandatory but recommended.

[AVR.Core.Attributes.ConsoleCommand("run_command", "Prints a hello world")]
static void run_command() {
print("Hello World");
}

This examples creates a simple "echo" command, which outputs the first argument given to the command. The second parameter (1), defines the minimum amount of arguments a command requires. Providing less will output a warning message to the user.

[AVR.Core.Attributes.ConsoleCommand("echo_command", 1, "Replies with the same string")]
static void echo_command(string arg) {
print(arg);
}

This example echoes the second parameter passed. (So the command "echo_second_word hello world" will output "world").

[AVR.Core.Attributes.ConsoleCommand("echo_second_word", 2)]
static void echo_second_word(string[] args) {
print(args[1]);
}

Definition at line 42 of file AVR_Attributes.cs.