Skip to main content

Making your own commands

Introduction

Commands can be used for quickly testing your game and fixing small bugs without having to rebuild.

Creating

To Create a command go to Create/qASIC/Console Command. It will be automatically added to the rest upon playing.

caution

Script templates won't work until you restart the editor!

Details

Inside of your new script you can change the 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" };

Handling execution

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 messages from the command. 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!");
break;
case 1:
LogError("This is an error message");
break;
default:
NoOptionException(result.ToString());
break;
}
}