How to display actor name in conversation.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
diccon
Posts: 27
Joined: Wed Sep 23, 2020 2:20 pm

How to display actor name in conversation.

Post by diccon »

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!
User avatar
Tony Li
Posts: 22137
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to display actor name in conversation.

Post by Tony Li »

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:

Code: Select all

public string GetDisplayName(string actorName)
{
    return DialogueLua.GetLocalizedActorField(actorName, "Display Name);
}
Then register it with Lua so you can use it like:

Let us go visit [lua(GetDisplayName("OtherNPC"))].
diccon
Posts: 27
Joined: Wed Sep 23, 2020 2:20 pm

Re: How to display actor name in conversation.

Post by diccon »

Awesome, thanks for your quick reply as always!
User avatar
Tony Li
Posts: 22137
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to display actor name in conversation.

Post by Tony Li »

Glad to help!
Post Reply