Page 1 of 1

setting variable as Portrait name

Posted: Sun Nov 22, 2020 4:56 am
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,

Re: setting variable as Portrait name

Posted: Sun Nov 22, 2020 8:10 am
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.

Re: setting variable as Portrait name

Posted: Sun Nov 22, 2020 8:48 am
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.

Re: setting variable as Portrait name

Posted: Sun Nov 22, 2020 8:53 am
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.

Re: setting variable as Portrait name

Posted: Sun Nov 22, 2020 8:57 am
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?

Re: setting variable as Portrait name

Posted: Sun Nov 22, 2020 9:05 am
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.

Re: setting variable as Portrait name

Posted: Sun Nov 22, 2020 9:37 am
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;
            }
        }

Re: setting variable as Portrait name

Posted: Sun Nov 22, 2020 9:49 am
by Tony Li
Yes, that's correct.