Making your own commands
Introduction
Commands can be used for quick debugging on the spot. They remove the need to rebuild your game if there's any small issue that prevents you from playing.
Creating
To Create a command navigate to Create/qASIC/Console Command. It will be automatically added to the rest upon playing.
Customization
Inside of your new script you can change name, description, help message, state and aliases. Description is used for displaying brief information about a command in the help list, while the help message is a detailed message about the usage of the command that will be displayed while displaying detailed help for a command (e.g help ExampleCommand).
public override bool Active { get; } = true;
public override string CommandName { get; } = "example command";
public override string Description { get; } = "description for help";
public override string Help { get; } = "This is a detailed description for help";
public override string[] Aliases { get; } = new string[] { "alias1", "alias2" };Writing your own command
Upon calling, everything in the run method will be executed. Most of the time you want to check for the correct argument count at the start by using CheckForArgumentCount or CheckForArgumentCountMin.
public override void Run(List<string> args)
{
//Example command
if(!CheckForArgumentCount(args, 0)) return;
Log("Hello world!", "default");
}Logging
There are multiple ways to log simple messages. For more detailed description visit Logging messages.
public override void Run(List<string> args)
{
//Example command
if(!CheckForArgumentCount(args, 1)) return;
if(!int.TryParse(args[1], out int result))
{
ParseException(args[1], "int");
return;
}
switch(result)
{
case 0:
Log("Hello world!", "default");
break;
case 1:
LogError("This is an error message");
break;
default:
NoOptionException(result.ToString());
break;
}
}Last updated