LethalOS
An in-game terminal library, which allows you to easily create menus, categories, and programmable modules. Allows for a clean and easy way to implement your mods.
模組介紹 作者原文
Creating Menus, Categories, and Modules in LethalOS.API
Introduction
LethalOS.API provides a flexible system for managing modules within Lethal Company's terminal environment. This guide demonstrates how to create menus, categories, and modules using the API.
Creating a Menu
-
// Creating a menu instance
Menu mainMenu = new Menu("Main Menu", "Description of the main menu", "main", "John Doe");
// Finalizing and adding the menu to the terminal, do this after adding categories and their respective modules
mainMenu.Finished();
Adding Categories to the Menu
-
// Creating a category instance
Category moonCategory = new Category("Moon", "Moon-related modules", "moon");
// Adding the category to the main menu, do this after adding the modules to the category
mainMenu.AddCategory(moonCategory);
Adding Modules to Categories
-
Creating a Custom Module Class
using LethalOS.API;
public class CustomModule: ModuleBase
{
public CustomModule(string displayName, string displayDescription, string keyword, bool requiresHost, bool toggled): base(displayName, displayDescription, keyword, requiresHost, toggled)
{
// Custom initialization code
}
public override void OnAdded()
{
// Custom Logic when the module is first added to the terminal
}
public override void OnEnabled()
{
// Custom logic when the module is enabled
//Change the current text on the terminal, does not effect the existing terminal node
ChangeScreenText("New Text", true);
//Updates the current node with a new one, this will effect the existing terminal node
UpdateNode(newNode: );
}
// Other overrideable lifecycle methods can be implemented here
}
Adding Custom Modules to Categories
// Creating a custom module instance
CustomModule moonInfo = new CustomModule("MoonInfo", "Display moon information", "MoonInfo", false, false);
// Adding the module to the 'moon' category
moonCategory.AddModule(moonInfo);
Retrieving Modules from Categories
-
// Retrieving a module by its name from the 'moon' category
ModuleBase retrievedModule = moonCategory.GetModuleByName("MoonInfo");
// Retrieving a module by its class from the 'moon' category
CustomModule moonModule = moonCategory.GetModule();
Example Code
-
// Creating a menu instance
Menu mainMenu = new Menu("Main Menu", "Description of the main menu", "main", "John Doe");
// Creating a category instance
Category moonCategory = new Category("Moon", "Moon-related modules", "moon");
// Creating a custom module instance
CustomModule moonInfo = new CustomModule("MoonInfo", "Display moon information", "MoonInfo", false, false);
// Adding the module to the 'moon' category
moonCategory.AddModule(moonInfo);
// Adding the category to the main menu
mainMenu.AddCategory(moonCategory);
// Finalizing and adding the menu to the terminal
mainMenu.Finished();
// Retrieving a module by its name from the 'moon' category
ModuleBase retrievedModule = moonCategory.GetModuleByName("MoonInfo");
if (retrievedModule!= null)
{
Console.WriteLine("Module Found: " + retrievedModule.DisplayName);
}
else
{
Console.WriteLine("Module Not Found.");
}
// Retrieving a module by its class from the 'moon' category
CustomModule moonModule = moonCategory.GetModule();
if (moonModule!= null)
{
Console.WriteLine("Custom Module Found: " + moonModule.DisplayName);
}
else
{
Console.WriteLine("Custom Module Not Found.");
}
安裝與使用 安裝:BepInEx 外掛
- 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
- 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
- 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
- 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。
帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。