-
Notifications
You must be signed in to change notification settings - Fork 0
Other ConsoleCommands
Mart Kartasev edited this page Sep 2, 2021
·
1 revision
Talewords has provided an attribute to mark methods with fitting signatures as usable from console:
[TaleWorlds.Library.CommandLineFunctionality.CommandLineFunction(string name, string groupname)]
Lets look at an example:
public class MyConsoleCommands
{
//Note that when running the command, the pattern is <category>.<command_name>
[CommandLineFunctionality.CommandLineArgumentFunction("command_name", "category")]
public static string SomeConsoleMethod(List<string> consoleArguments)
{
DoSomethingWith(consoleArguments);
var consoleOutput = "Hello world!";
return consoleOutput;
}
}
The command can be used from the game console. Open it with "Alt + `" and type ".<command_name>". Arguments are separated by "space".
- The method marked with attribute has to be static otherwise it wont be visible in the console.
- The method signature must declare List as its argument.
- The method _must_return a string for console output to inform the invoker that the command has been executed.
- If your command is not supposed to work outside of the campaign, add this to the beginning of method to avoid crashes:
if (!CampaignCheats.CheckCheatUsage(ref CampaignCheats.ErrorType))
return CampaignCheats.ErrorType;
- It is best not to clutter the classes of your feature with method signatures of console commands. A good practice is to add separate wrapper classes and static methods with the console command attributes.
That's all. Don't forget you are wonderful ;D
- Campaign AI
- MobileParty
- Clan
- Kingdom
- Mission AI
- Agent
- Formation
- Team
- Decision Utility System
- Casting Behaviors