TTPlugins is the user plugin framework for Terraria Tweaker 2, a Terraria client patcher. TTPlugins is included with Terraria Tweaker 2.3+ and provides a convenient means for users to modify Terraria by writing high-level, dynamic patches in C#.
TTPlugins uses the fantastic Harmony library to patch Terraria at runtime. Harmony modifies the execution flow of .NET applications in memory and does not touch any on-disk files.
Below is an example of a very basic but complete *.cs plugin file that gives the player superspeed. This is the entire plugin source code. Optional plugin features are not present in this example.
using System;
using com.tiberiumfusion.ttplugins.HarmonyPlugins;
namespace MyPlugin
{
public class SuperSpeed : HPlugin
{
public override void PrePatch()
{
CreateHPatchOperation("Terraria.Player", "UpdateEquips", "SuperSpeedPatch", HPatchLocation.Prefix);
}
public static void SuperSpeedPatch(Terraria.Player __instance)
{
__instance.moveSpeed += 20.0f;
}
}
}
Please refer to the Wiki for primary documentation, including step-by-step tutorials and general library reference.
This repository contains several example plugins that cover some common & advanced plugin tasks.
Complete reference docs for TTPlugins can be found here. Please note that this material has very sparse descriptions & remarks and may only be helpful to advanced plugin authors. The primary how-to documentation is on the Wiki.