I want to refer to the name of an actor who is not the actor or conversant in a conversation and I can't get it to show up.
I am using this in the Dialogue Text field:
Let us go visit [lua(Actor["OtherNPC"].DisplayName)].
There is no syntax error but an empty string is returned, even though the actor definitely exists. Am I doing this wrong?
Thanks!
How to display actor name in conversation.
Re: How to display actor name in conversation.
Hi,
The "Display Name" field has a space in it, and spaces are handled as underscores in Lua tables (more info), so try:
Let us go visit [lua(Actor["OtherNPC"].Display_Name)].
Note: If you're localizing display names to different languages, you can write a C# method that returns the localized version of an actor's display name, such as:
Then register it with Lua so you can use it like:
Let us go visit [lua(GetDisplayName("OtherNPC"))].
The "Display Name" field has a space in it, and spaces are handled as underscores in Lua tables (more info), so try:
Let us go visit [lua(Actor["OtherNPC"].Display_Name)].
Note: If you're localizing display names to different languages, you can write a C# method that returns the localized version of an actor's display name, such as:
Code: Select all
public string GetDisplayName(string actorName)
{
return DialogueLua.GetLocalizedActorField(actorName, "Display Name);
}
Let us go visit [lua(GetDisplayName("OtherNPC"))].
Re: How to display actor name in conversation.
Awesome, thanks for your quick reply as always!
Re: How to display actor name in conversation.
Glad to help!