Page 1 of 1

Set player display name in code

Posted: Thu May 30, 2019 7:02 pm
by HeroicMaou
Hey guys, new to the forum but I've been using Dialogue System for close to a month. In each usage I've always had names for the characters. This time while attempting an RPG type game, I'm trying to have the players display name be of their choosing. At first I tried to set it in code using DialogueLua.SetActorField. It didn't work though. I have a feeling I'm overlooking something. I set up my own on screen keyboard since I'm using an xbox controller.

Any help on this is greatly appreciated. I eventually found out how to set up my own saver scripts on my own but this is stopping me in my tracks.

Re: Set player display name in code

Posted: Thu May 30, 2019 8:35 pm
by Tony Li
Hi,

DialogueLua.SetActorField is the way to do it. The trick is to set the Display Name field:

Code: Select all

DialogueLua.SetActorField("Player", "Display Name", "Heroic Maou");
If you're making an RPG with a character creation mode, you'll probably want to use the code above.

However, you can also use the TextInput() sequencer command to ask the player's name in a conversation. This is more common in chat games and visual novels. Since TextInput() stores the player's answer in a variable, it requires two nodes so you can copy that variable's value into the player's Display Name field:
  • Dialogue Text: "What's your name?"
    Sequence: TextInput(Text Field UI, Your Name, playerName)
  • Dialogue Text: "What's your name?"
    Script: Actor["Player"].Display_Name = Variable["playerName"]

You're almost certainly not using the older version 2.0.8. If you are, update to the latest. Version 2.0.8 had a bug with Display Name fields.

Re: Set player display name in code

Posted: Fri May 31, 2019 1:20 pm
by HeroicMaou
It's a fresh download from maybe 1 month ago, so it shouldn't be 2.0.8. . It says there's an update though, so I'm gonna see if that helps. Is there a certain way to using DialogueLua? In the script I'm testing it in the start function. i have it as

Code: Select all

private void Start()
    {
        DialogueLua.SetActorField("Player", "Display Name", "Heroic Maou");
    }
Is there more to it than that? I have using PixelCrushers and using PixelCrushers.DialogueSystem in the script. Is there more setup to use DialogueLua?

Re: Set player display name in code

Posted: Fri May 31, 2019 1:31 pm
by HeroicMaou
Okay so I'm a bit confused.
It's working, as I can use GetActorField and debug to check it. It shows up in the debug as the new name "Heroic Maou" instead of "Temp Display". However, in the DialogueManager window it isn't changing. Is this intended?

Re: Set player display name in code

Posted: Sat Jun 01, 2019 8:10 am
by Tony Li
Hi,

If you're referring to the Dialogue Editor window, then yes it's working as intended. The Dialogue Editor shows the design-time values of the dialogue database, not the runtime values. The only exception is the Watches tab, which is only available at runtime and lets you add watches on runtime values.