Skip to content

Mod Call

emyhrberg edited this page Sep 16, 2025 · 2 revisions

Mod Call

This wiki is dedicated to fellow mod developers with chat tags in your mods. After following this guide, your mod will have full support for the autocompletion feature offered by Chat+. To get started, follow the guide below. If you get stuck, you can view the example code or example demo.

RegisterTag

The RegisterTag call supports adding a custom tag and a list of tags. It accepts the following arguments.

Arguments

[0] Entry Type

string - The first argument needed is the message type, which is always simply "RegisterTag".

[1] Tag

string - The second argument is the tag type, which is the tag you registered in ChatManager, e.g t.

[2] Tags

IEnumerable<string> - The third and final argument is the collection of tags to display. Please remember to supply the full tag, e.g new[] { "[t:one]", "[t:two]" }, ....

Example Code

public class TagExampleSystem : ModSystem
{
    public static Dictionary<string, string> ExampleMap = new()
    { // A simple mapping that transforms "smile" to ":)" and "sad" to ":(".
        ["smile"] = ":)",
        ["sad"] = ":("
    };

    public override void PostSetupContent()
    {
        ChatManager.Register<ExampleTagHandler>(["t"]); // Make [t:xxx] a valid chat tag.
        Mod ChatPlus = ModLoader.GetMod("ChatPlus"); // Get ChatPlus

        IEnumerable<string> tags = 
        [ 
            "[t:smile]",
            "[t:sad]",
        ];

        // Register tags with ChatPlus
        ChatPlus.Call
        (
            "RegisterTag", 
            "t", // enter the tag exactly as registered with ChatManager
            tags // the collection of tags to register
        );
    }
}

public class ExampleTagHandler : ITagHandler
{
    public TextSnippet Parse(string text, Color baseColor = default, string options = null)
    {
        // Parse e.g [t:smile] to ":)"
        if (TagExampleSystem.ExampleMap.TryGetValue(text, out string mapped))
            return new TextSnippet(mapped);

        return new TextSnippet(text);
    }
}

Example Demo

dotnet_Zd1iMXUQdK.mp4

RegisterTagProvider

On request, to provide more flexible autocomplete support, an additional Mod.Call was added called RegisterTagProvider.

See more details in the official implementation here: ChatPlus:Mod.Call()

Clone this wiki locally