SimpleCommandAPI

v1.0.2·Updated 2024-01-10

C# API plugin for Lethal Company

About this mod Author’s original text

SimpleCommand.API

[!NOTE]

This README file might be outdated. Always check out the original GitHub Page.

This plugin is designed to help developers. So if certain features are missing, please do not hesitate to contact me.

This plugin currently features:

  • Mod Command List with all available mod commands
  • Nested Command Structure

Oversimplified

Introduction

To create new commands for the Terminal, this plugin uses a nested structure of a class called SimpleCommandModule. This allows the user to create complex command structures with ease. Every command will get added to the SimpleCommandList, if not specified otherwise.

[!IMPORTANT]

This documentation does not explain how to create a plugin in general. Please look up how to create a plugin first.

Getting Started

Start by downloading this plugin and referencing it inside of your IDE of choice. For Visual Studio 2022, you can check out this documentation.

Reference as BepInDependency

For the plugin to work best, add it as BepInDependency above your initial plugin class.

[BepInDependency(SimpleCommand.API.MyPluginInfo.PLUGIN_GUID)]

public class MyPlugin: BaseUnityPlugin

SimpleCommandModule

The SimpleCommandModule class has the following properties:

SimpleCommandModule reviveModule = new SimpleCommandModule()

{

DisplayName (string)

What the player needs to type for the command to trigger, e.g. "revive"

DisplayName: "revive",

Method (Func)

This method will get called if the player enters the command.

Method: ReviveDeadPlayer,

[!WARNING]

Your initial method needs to have Terminal as a parameter and a TerminalNode as a return. The TerminalNode will be your text on the terminal after your method was invoked. You can see how to create a TerminalNode here.

Description (string) (optional)

This text will appear in the command list. Tell the player what this command does.

Description: "Revive a dead player"

Abbreviations (string) (optional)

Shorter form of the word, which also works. This value can also contain several abbreviations.

Abbreviations: ["rev", "reviv"],

Arguments (string) (optional)

If the command has dynamic input, you can list what values the player has to type (shows in list later).

Arguments: ["number"],

HasDynamicInput (bool) (optional)

If the command awaits dynamic input like numbers, otherwise it will check for the children names.

HasDynamicInput: false,

HideFromCommandList (bool) (optional)

If this command is allowed to appear on on the command list. Useful, if you have a command structure like "buy coffee", but you don't actually want to display "buy" as extra.

HideFromCommandList: false,

IgnoreModule (bool) (optional)

Useful for plugins that already have their own system and just want to appear on the command list.

IgnoreModule: false,

ChildrenModules (SimpleCommandModule) (optional)

SimpleCommandModules that come after the current module, e.g. revive "player"

ChildrenModules: [newModule]

All methods

AddSimpleCommand(SimpleCommandModule)

Adds the SimpleCommandModule to the command list.

[!IMPORTANT]

Please pay attention to duplicates. If your command name already exists in other plugins, it will usually load first, but errors may still occur.

AddSimpleCommands(SimpleCommandModule)

Just an additional way of adding commands to the list via array.

GetInputValue(Terminal terminal)

Returns the complete string of what was written and submitted on the terminal. Terminal reference needed.

GetInputValue(Terminal terminal, int index)

Returns a string array of the last wordsa depending on what index will be. (Counts backwards) Terminal reference needed aswell.

RemovePunctuation(string s)

Removes every punctuation character in the given string and converts it to lowercase.

TerminalNode

TerminalNodes are a default class defined by the Lethal Company developer. It will look something like this:

public class TerminalNode: ScriptableObject

{

[TextArea(2, 20)]

public string displayText;

public string terminalEvent;

[Space(5f)]

public bool clearPreviousTe

Install & use Install: BepInEx plugin

  1. The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
  2. Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
  3. Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
  4. Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.

Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.

Dependencies

Install these first, or the mod will not work:

BepInEx-BepInExPack

File & checksum

Filename
SimpleCommandAPI-1.0.2.zip
File size
59.4 KiB