-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Welcome to the SR2Essentials wiki!
If you've made a Melonloader Mod and you want to add a console command, then add the SR2Essentials.dll as a dependency. Next copy this Template:
using Il2Cpp;
public class TemplateCommand : SR2CCommand
{
public override string ID { get; } = "test";
public override string Usage { get; } = "test";
public override string Description { get; } = "This is a test command";
public override bool Execute(string[] args)
{
if (args != null)
{
SR2Console.SendError($"The '<color=white>{ID}</color>' command takes no arguments");
return false;
}
SR2Console.SendMessage("Successfully executed this command :)");
return true;
}
}
Then register the command once using SR2Console.RegisterCommand(SR2CCommand cmd) after the the scenes "SystemCore","MainMenuCamera" have been loaded.
For example in the Scene "CompanyLogoScene" (The next scene) in your Main Class
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
if (sceneName == "CompanyLogoScene")
{
SR2Console.RegisterCommand(new TemplateCommand());
}
}
The ID is what the player should enter to execute your command. (Always lower case with no space) e.g "give"
The Usage is what structure the user should follow. (<>is required, [] is optional) e.g "give [amount]"
The Description is what the command does. e.g "Gives the Player Items"
The args string array is every single other word typed after the Id. (The ID is not included!)
When the command is finished return true if it was successful. e.g The player got the items or return false if it wasn't successful. e.g The player used not enough arguments/Save Game is not loaded/ etc.
SR2Console.SendMessage(string message) is used for sending messages to the console.
SR2Console.SendError(string error) is used to send an error message to the console.