Date uploaded | 11 months ago |
Version | 1.3.1 |
Download link | NotAtomicBomb-TerminalApi-1.3.1.zip |
Downloads | 24277 |
Dependency string | NotAtomicBomb-TerminalApi-1.3.1 |
This mod requires the following mods to function
BepInEx-BepInExPack
BepInEx pack for Mono Unity games. Preconfigured and ready to use.
Preferred version: 5.4.2100README
TerminalApi
Overview
Terminal Api provides a nice a easy way to add and modify terminal keywords. It allows you to create and add them whenever you want in your code as it will automatically add the keywords when it is safe to do so.
See Test Plugin and Time Command mod for an example case of this api.
Installation
Just drag and drop the BepInEx folder to your Lethal Company root folder(Where the Lethal Company.exe is). Or just use the thuderstore mod loader, much easier.
Table of Contents
- Adding Commands
- Events
- Creating Terminal Keywords
- Creating Terminal Nodes
- Adding and Managing Keywords
- Updating Keywords
- Getting Keywords
- Compatible Nouns
[!WARNING] Make sure you are not adding duplicate keywords. I do plan on having a system to handle this in the future.
Adding Commands
This api give you an easy way to add terminal commands via the AddCommand
method.
This methods returns nothing.
There is one method:
AddCommand(string commandWord, string displayText, string verbWord = null, bool clearPreviousText)
Example:
AddCommand("frank", "Frank is not here\n", "get", true)
Will display Frank is not here
when get frank
or frank
is sent in the terminal
Events
There are multiple subscribable events that this api provides.
They can be found in the TerminalApi.Events
namespace.
Here is a list of them:
TerminalAwake
- Runs when the terminal is fully awake.TerminalWaking
- Runs when the terminal is waking up.TerminalStarted
- Runs when the terminal is fully started.TerminalStarting
- Runs when the terminal starts.TerminalBeginUsing
- Runs when the player begins using.TerminalBeganUsing
- Runs after begins using.TerminalExited
- Runs when the player exits the terminal.TerminalParsedSentence
- Runs when the player sends a command.TerminalTextChanged
- Runs when the player types in the terminal.
For more information please check Test Plugin.
Creating Terminal Keywords
To create a terminal keyword, you can use the CreateTerminalKeyword
method.
There are two overloaded methods available:
CreateTerminalKeyword(string word, bool isVerb = false, TerminalNode triggeringNode = null)
CreateTerminalKeyword(string word, string displayText, bool clearPreviousText = false, string terminalEvent = "")
Example:
TerminalKeyword keyword = TerminalApi.CreateTerminalKeyword("die", "No don't");
Creating Terminal Nodes
If you don't know what terminal nodes are, they essential hold information that the terminal uses when the keyword associated with the node is sent. For most cases, when a word is sent, it will display the nodes displayText
. You can create a node by using the CreateTerminalNode
method.
[!NOTE] You can pretty much ignore the terminalEvent parameter. Unless you know what you're doing.
There is one method available:
CreateTerminalNode(string displayText, bool clearPreviousText = false, string terminalEvent = "")
Example:
TerminalNode node = TerminalApi.CreateTerminalNode("Hello world");
Adding Keywords
Once you have your keyword ready to add you can use the AddTerminalKeyword
to add the keyword.
There is one method available:
AddTerminalKeyword(TerminalKeyword terminalKeyword)
Example:
TerminalApi.AddTerminalKeyword(keyword);
Updating Keywords
Use UpdateKeyword
to update any keyword that already exists.
There is one method available:
UpdateKeyword(TerminalKeyword terminalKeyword)
Example:
TerminalApi.UpdateKeyword(keyword);
Getting Keywords
Use GetKeyword
to get an already existing keyword.
This uses the keyword's word to find it.
There is one method available:
GetKeyword(string keyword)
Example:
TerminalKeyword gottenKeyword = TerminalApi.GetKeyword("die");
Compatible Nouns
[!IMPORTANT] If you use compatible nouns, make sure that verb keyword and noun keywords are added to the terminal!
Every keyword has a field for an array of CompatibleNoun
, not all keywords use it though. Only keywords marked as verbs use it.
It allows for verb-noun combos like check fish
. The verb being check
and the noun being fish
.
Adding Compatible Noun To Newly Created Keyword
In TerminalApi there is an exstension method that allows you to quickly add a CompatibleNoun
to your verb keyword.
There are three of these overloaded methods:
AddCompatibleNoun(this TerminalKeyword terminalKeyword, TerminalKeyword noun, TerminalNode result)
AddCompatibleNoun(this TerminalKeyword terminalKeyword, string noun, TerminalNode result)
AddCompatibleNoun(this TerminalKeyword terminalKeyword, string noun, string displayText)
AddCompatibleNoun(this TerminalKeyword terminalKeyword, TerminalKeyword noun, string displayText, bool clearPreviousText = false)
Here is an example:
TerminalKeyword verbKeyword = TerminalApi.CreateTerminalKeyword("check", true);
TerminalKeyword nounKeyword = TerminalApi.CreateTerminalKeyword("fish");
TerminalNode triggerNode = TerminalApi.CreateTerminalNode("There are no fish\n", true);
verbKeyword = verbKeyword.AddcompatibleNoun(nounKeyword, triggerNode);
TerminalApi.AddTerminalKeyword(verbKeyword);
TerminalApi.AddTerminalKeyword(nounKeyword);
In the example above, if you were to type check fish
into the terminal you would get There are no fish\n
.
Adding Compatible Noun to Existing Keyword
Use AddCompatibleNoun
method to add a CompatibleNoun
to an existing keyword.
The Noun should also already exist.
There are four overloaded methods:
AddCompatibleNoun(TerminalKeyword verbKeyword, string noun, string displayText, bool clearPreviousText = false)
AddCompatibleNoun(TerminalKeyword verbKeyword, string noun, TerminalNode triggerNode)
AddCompatibleNoun(string verbWord, string noun, TerminalNode triggerNode)
AddCompatibleNoun(string verbWord, string noun, string displayText, bool clearPreviousText = false)
Example:
TerminalApi.AddCompatibleNoun("check", "die", "You are not dead.");
The above code would add the existing die
noun to check and when check die
is typed into the terminal You are not dead.
would display.
Updating Existing Compatible Noun
Use UpdateKeywordCompatibleNoun
method to update an existing compatible noun on a verb keyword.
There is four method:
UpdateKeywordCompatibleNoun(TerminalKeyword verbKeyword, string noun, TerminalNode newTriggerNode)
UpdateKeywordCompatibleNoun(string verbWord, string noun, TerminalNode newTriggerNode)
UpdateKeywordCompatibleNoun(TerminalKeyword verbKeyword, string noun, string newDisplayText)
UpdateKeywordCompatibleNoun(string verbWord, string noun, string newDisplayText)
Example:
TerminalApi.UpdateKeywordCompatibleNoun("check", "fish", "There are 100 fish.")
With the above code check fish
you should get There are 100 fish.
in the terminal.
CHANGELOG
Releases
Version 1.0.0
- Initial Release
Version 1.0.1
- Updated Github link
Version 1.0.2
- Added Installation Instructions to README
Version 1.0.3
- Added proper tags to mod
Version 1.1.0
- Added a subscribable event for Terminal Awake
TerminalApi.Patches.TerminalAwakePatch.TerminalAwake
- Some file organizing
- Added CHANGELOG
Version 1.2.0
- Added more events
- Events are now located at
TerminalApi.Events
- Added the
AddCommand
method to easily add terminal commands - Update README
Version 1.3.0
- Added
TerminalTextChanged
event
Version 1.3.1
- Fixed bug with TextChanged event
Version 1.3.2
Version 1.4.0
- Added DeleteKeyword
- Added GetTerminalInput
- Added SetTerminalInput
Version 1.5.0
- Added CommandInfo class
- CommandInfo allows for adding callbacks functions
- Added AddCommand overload that accepts CommandInfo
- Added AddTerminalKeyword overload that also accepts CommandInfo
- Added a config option that allows users to disable TerminalApi logs
- Added NodeAppendLine, appends a line of text to a node via its keyword
Version 1.5.1
- Updated README
Version 1.5.2
- Added Null Check for CommandInfo.Category in AddTerminalKeyword
Version 1.5.4
- Fixed a bug with NodeAppendLine
Version 1.5.5
- Added License to abide by new guidelines