tModLoader v2024.09
A mod to make and play Terraria mods
NetworkText Class Reference

Represents text that will be sent over the network in multiplayer and displayed to the receiving user in their selected language. Use FromKey(string, object[]) to send a localization key and optional substitutions. LocalizedText.ToNetworkText() can be used directly as well for the same effect.Use FromFormattable(string, object[]) to send a string with string formatting substitutions and associated substitutions. This is typically used with language-agnostic strings that don't need a localization entry, such as "{0} - {1}".Use FromLiteral(string) to send a string directly. This should be used to send text that can't be localized. More...

Public Member Functions

int GetMaxSerializedSize ()
 
void Serialize (BinaryWriter writer)
 
override string ToString ()
 

Static Public Member Functions

static NetworkText Deserialize (BinaryReader reader)
 
static NetworkText DeserializeLiteral (BinaryReader reader)
 
static NetworkText From (object o)
 
static NetworkText FromFormattable (string text, params object[] substitutions)
 Creates a NetworkText object from a string with string formatting substitutions and associated substitutions. This is typically used with language-agnostic strings that don't need a localization entry, such as "{0} - {1}". More...
 
static NetworkText FromKey (string key, params object[] substitutions)
 Creates a NetworkText object from a localization key and optional substitutions. The receiving client will see the resulting text in their selected language. More...
 
static NetworkText FromLiteral (string text)
 Creates a NetworkText object from a string. Use this for text that can't be localized. More...
 

Static Public Attributes

static readonly NetworkText Empty = FromLiteral("")
 

Detailed Description

Represents text that will be sent over the network in multiplayer and displayed to the receiving user in their selected language.

Use FromKey(string, object[]) to send a localization key and optional substitutions. LocalizedText.ToNetworkText() can be used directly as well for the same effect.

Use FromFormattable(string, object[]) to send a string with string formatting substitutions and associated substitutions. This is typically used with language-agnostic strings that don't need a localization entry, such as "{0} - {1}".

Use FromLiteral(string) to send a string directly. This should be used to send text that can't be localized.

Member Function Documentation

◆ FromFormattable()

static NetworkText NetworkText.FromFormattable ( string  text,
params object[]  substitutions 
)
static

Creates a NetworkText object from a string with string formatting substitutions and associated substitutions. This is typically used with language-agnostic strings that don't need a localization entry, such as "{0} - {1}".

Parameters
text
substitutions
Returns

◆ FromKey()

static NetworkText NetworkText.FromKey ( string  key,
params object[]  substitutions 
)
static

Creates a NetworkText object from a localization key and optional substitutions. The receiving client will see the resulting text in their selected language.

Parameters
key
substitutions
Returns

◆ FromLiteral()

static NetworkText NetworkText.FromLiteral ( string  text)
static

Creates a NetworkText object from a string. Use this for text that can't be localized.

Parameters
text
Returns