Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for hook addition to message log #361

Closed
rrryutaro opened this issue Jun 12, 2018 · 4 comments
Closed

Suggestion for hook addition to message log #361

rrryutaro opened this issue Jun 12, 2018 · 4 comments

Comments

@rrryutaro
Copy link

I am using Google translation because I can not speak English.

Description

Suggestion.
I would like to retrieve the contents of Main.NewText.
The following usage is assumed.

  • immediate translation of messages
  • Output to file
  • Original processing according to the message

Code example

[Terraria.Main.cs]
    public static void NewText(string newText, byte R = 255, byte G = 255, byte B = 255, bool force = false)
    {
        ModHooks.OnNewText(ref newText, new Microsoft.Xna.Framework.Color(R, G, B), force);
            :

[Terraria.ModLoader.ModHooks.cs]
    public abstract partial class Mod
            :
        public virtual void OnNewText(ref string newText, Color color, bool force)
        {
        }
            :
    internal static class ModHooks
            :
        internal static void OnNewText(ref string newText, Color color, bool force)
        {
            foreach (Mod mod in ModLoader.mods.Values)
            {
                mod.OnNewText(ref newText, color, force);
            }
        }
@JavidPack
Copy link
Collaborator

I don't see much use for this, and it would be very easy to simply check Main.chatLine in an Update method and do whatever you want with them.

@Chicken-Bones
Copy link
Member

I approve this, especially due to the ref parameter. I also request a bool return to optionally cancel the message entirely.

@Chicken-Bones
Copy link
Member

May require additional support for multiplayer, also I'm not sure what state our commands are in

@Chicken-Bones
Copy link
Member

Use the MonoMod hooking support coming in 0.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants