Page 1 of 1

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

Posted: Sun Feb 20, 2022 8:01 pm
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. :)

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

Posted: Sun Feb 20, 2022 8:43 pm
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"