Once you have the TR Tools plugin referenced in your project, there are a few more steps you should take to make your mod work well with the API.
First, make sure the top of any scripts your using include the TinyResort namespace, like so:
using TinyResort;
Next, tell BepinEX that your plugin depends on TR Tools to run properly. This ensures that it always runs after TR Tools.
[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
[BepInDependency("dev.TinyResort.TRTools")]
public class YourPluginName : BaseUnityPlugin {
Lastly, you'll want to initialize your plugin with TR Tools like so:
public static TRPlugin plugin;
private void Awake() {
plugin = TRTools.Initialize(this, yourNexusID, yourChatTrigger);
}
This serves a few purposes:
plugin.harmony
).Once you've initialized your plugin, you can call plugin.Log("Hello World!")
to log something to the BepInEx console. The only reason this is preferred over standard BepIn logging is that this function only logs to the console if the “Debug Mode” setting in your plugin's config file is True. This is useful when mod users are experiencing issues that you're struggling to reproduce. You can keep your logging in your release and if a user experiences issues they can set Debug Mode to True and provide you with more information.
You can force it to log regardless of the Debug Mode setting by setting the second parameter to false: plugin.Log("Hello World!", false)
You can also log warnings and errors with plugin.LogWarning("Hello World!")
and plugin.LogError("Hello World!")
Logged errors will always appear in the console regardless of Debug Mode status.
This is a way to very quickly patch a base game function using harmony in one line.
plugin.QuickPatch(typeof(BaseGameClass), "BaseGameMethod", typeof(YourClass), "YourPrefixMethod", "YourPostfixMethod");
Many other features of TR Tools are accessed through your plugin reference. This includes adding custom chat commands, licenses and items. For more information, read the Chat Commands (Modders) page, Custom Licenses page, and Custom Items page.