Solo-Ion
Dungeon Spirit
That part of the guide contains more information about NetworkText than I do... but I've just had a quick little look myself to see if I can work something out.I only found this:
NetMessage.SendData
If you are using a method that had “” as the string parameter, you can just change “” to null.
If you are using MessageID.ChatText, aka “25”, to send a chat string, you need to change it like this:
if (Main.netMode == 0)
{
Main.NewText(Lang.misc[29].Value, 50, 255, 130, false);
}
if (Main.netMode == 2)
{
NetMessage.BroadcastChatMessage(Lang.misc[29].ToNetworkText(), new Microsoft.Xna.Framework.Color(50, 255, 130), -1);
}
If you weren’t using a vanilla message, you would first add a ModTranslation in Load and then use that:
Mod.Load:
ModTranslation text = CreateTranslation("VolcanoWarning");
text.SetDefault("Did you hear something....A Volcano! Find Cover!");
AddTranslation(text);
Usage:
string key = "Mods.ExampleMod.VolcanoWarning";
Color messageColor = Color.Orange;
if (Main.netMode == 2) // Server
{
NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor);
}
else if (Main.netMode == 0) // Single Player
{
Main.NewText(Language.GetTextValue(key), messageColor);
}
I tried to use .ToNetworkText() after Main.chest[player.chest].name , but it didn't work and now I'm stuck again
.ToNetworkText() will only work on things in the Localization class and cannot be applied directly to a string. I think that something like 'Terraria.Localization.Language.GetText("ItemName." + Main.chest[player.chest].name).ToNetworkText()' may work in place of '
Main.chest[player.chest].name', but I haven't tested this. If all else fails, just use null in all NetMessages instead of a string. I really can't be of any more help.