setting variable as Portrait name

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

setting variable as Portrait name

Post by fkkcloud »

Hi,

How do I set a portrait name with a variable?
[var=PLAYER_NAME] for the portrait name area.

also, is there any place that I can check all the variable's data stored?

Thank you,
User avatar
Tony Li
Posts: 22050
Joined: Thu Jul 18, 2013 1:27 pm

Re: setting variable as Portrait name

Post by Tony Li »

Hi,

Set the actor's Display Name field. Example in Script field:

Code: Select all

Actor["Player"].Display_Name = "Bob Loblaw";
Example in C#:

Code: Select all

DialogueLua.SetActorField("Player", "Display Name", "Bob Loblaw");
In your Dialogue Text, [var=Actor] will be the Display Name (e.g., "Bob Loblaw").

See also the "Discover Name Example" on the Dialogue System Extras page. It shows how to change the name in the middle of a conversation.

To check the variables' current values, use the Dialogue Editor window's Watches tab (Menu > Add All Runtime Variables) or the Variable Viewer window.
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Re: setting variable as Portrait name

Post by fkkcloud »

Great.
I am doing

Code: Select all

        
        
        DialogueLua.SetVariable("PLAYER_NAME", nameField.text);

        DialogueLua.SetActorField("Player", "Display_Name", DialogueLua.GetVariable("PLAYER_NAME").asString);

It does not set the display name, it still uses the default value.
But "DialogueLua.GetVariable("PLAYER_NAME").asString"'s value is valid.


also, Does this gets saved for the game or temporarily for the session?


--

I don't have/see "Watches" tab in Dialogue Editor window. Maybe its in different UI? I have the latest Dialogue System version.
User avatar
Tony Li
Posts: 22050
Joined: Thu Jul 18, 2013 1:27 pm

Re: setting variable as Portrait name

Post by Tony Li »

Hi,

Change the second line to:

Code: Select all

DialogueLua.SetActorField("Player", "Display Name", DialogueLua.GetVariable("PLAYER_NAME").asString);
All Actor fields (including Display Name) are saved in saved games.

The Dialogue Editor's Watches tab is only visible in play mode.
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Re: setting variable as Portrait name

Post by fkkcloud »

Still no luck on the Display Name set..

I tried

Code: Select all

Disaply Name
first before

Code: Select all

 Display_Name
.

The variable is valid in console and watches.

Any other thing that I might 've missed?
User avatar
Tony Li
Posts: 22050
Joined: Thu Jul 18, 2013 1:27 pm

Re: setting variable as Portrait name

Post by Tony Li »

Are you changing the name while a conversation is active? If so, the new name will not appear until you start a new conversation, unless you use the technique shown in the Discover Name example.
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Re: setting variable as Portrait name

Post by fkkcloud »

Yes, I am changing during the conversation.

Okay I will look into Discover Name example

Edit:
I guess this is the trick

Code: Select all

        if (DialogueDebug.LogInfo) Debug.Log("Dialogue System: Changing " + actorName + "'s Display Name to " + newDisplayName);
        DialogueLua.SetActorField(actorName, "Display Name", newDisplayName);
        if (DialogueManager.IsConversationActive)
        {
            var actor = DialogueManager.MasterDatabase.GetActor(actorName);
            if (actor != null)
            {
                var info = DialogueManager.ConversationModel.GetCharacterInfo(actor.id);
                if (info != null) info.Name = newDisplayName;
            }
        }
User avatar
Tony Li
Posts: 22050
Joined: Thu Jul 18, 2013 1:27 pm

Re: setting variable as Portrait name

Post by Tony Li »

Yes, that's correct.
Post Reply