Logging messages
Introduction
Log messages can let you see what's wrong with your game. In qASIC you can easily display them and give them colors.
Logging
The simplest way of logging messages is using qDebug, but you can directly log with the GameConsoleController.
using qASIC;
using qASIC.Console;
using UnityEngine;
public class ExampleScript : MonoBehaviour
{
public void LogExample()
{
//Logging with the controller
GameConsoleController.Log("This is an example using the controller", "example color");
//Logging with qDebug
qDebug.Log("This is a normal message", "color is optional");
qDebug.LogWarning("This is a warning message");
qDebug.LogError("This is an error message");
}
}Logging in commands
While making your own commands, you can log as you would normally do, but it's faster and easier to do it directly through the command itself.
public class ExampleCommand : GameConsoleCommand
{
public override string CommandName { get; } = "example";
public override string Description { get; } = "example command";
public override void Run(List<string> args)
{
if (!CheckForArgumentCountMin(args, 1)) return;
Log("This is an example", "example color");
//Special
LogError("This is an error");
ParseException("[some value here]", "bool"); //Result: Couldn't parse [some value here] to bool!
NoOptionException("[unknown option]"); //Result: Option [unknown option] does not exist!
}
}Last updated