TiberiumFusion / TTPlugins

Dynamic user plugin system for Terraria Tweaker 2
GNU Lesser General Public License v3.0
10 stars 3 forks source link

TTPlugins

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#.

Dynamic patching

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.

How easy is it?

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;
        }
    }
}

For plugin authors

Please refer to the Wiki for primary documentation, including step-by-step tutorials and general library reference.

Example plugins

This repository contains several example plugins that cover some common & advanced plugin tasks.

Technical documentation

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.