Using the Player's name in dialogue when it's stored in a variable in a different script

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Rose
Posts: 17
Joined: Sat Feb 19, 2022 12:29 pm

Using the Player's name in dialogue when it's stored in a variable in a different script

Post by Rose »

Been searching on the forums for an answer to this one. I kind of get what I have to do, but still a little confused.

In my game, the player types what they want to call their character in an input field. What they enter in that gets stored in a variable called playername in a script called PlayerName.

I've looked into how to reference variables with Lua and tried doing it but not been successful so I'm assuming I'm doing something wrong.

Would super appreciate the help. :)
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Using the Player's name in dialogue when it's stored in a variable in a different script

Post by Tony Li »

Hi,

Once you have the player name, set the Player actor's Display Name.

For example, in C# you can set the player's name to "Rose" like this:

Code: Select all

DialogueLua.SetActorField("Player", "Display Name", "Rose");
In Lua (such as in a dialogue entry node's Script field), like this:

Code: Select all

Actor["Player"].Display_Name = "Rose"
Post Reply