Setting actors display name to a variable.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Murble
Posts: 7
Joined: Wed Jul 15, 2020 7:41 pm

Setting actors display name to a variable.

Post by Murble »

I want to change an actors display name after he writes it in a text field.
I know how to set a variable with a text field by entering in the dialogue text:

Code: Select all

[var=?playerName]
And I saw on an old post that you can change the display name in the Script with:

Code: Select all

Actor["Player"].Display_Name = "Alex"
However, I ran into two problems. First being that Actor["Player"].Display_Name = "Alex" doesn't seem to work. And the second being, if it did work, how do I make it take in the variable playerName instead.

I tried:

Code: Select all

Actor["Player"].Display_Name = Variable["playerName"]
But, that didn't work.

To put it into a simpler perspective, I simply want the dialogue to ask, "what is your name" and then have the player type a response. Then for the player to have that response set to his display name.

What I have now is one node having in the dialogue text:

Code: Select all

What is your name?[var=?playerName]
Then another node with this written in the Script section:

Code: Select all

Actor["Player"].Display_Name = Variable["playerName"]
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Setting actors display name to a variable.

Post by Tony Li »

Hi,

For efficiency, actors' Display Names are cached at the beginning of the conversation. To change an actor's Display Name in the middle of a conversation and have the change appear immediately, use the Lua function included in the "Discover Name Example" available on the Dialogue System Extras page.
Murble
Posts: 7
Joined: Wed Jul 15, 2020 7:41 pm

Re: Setting actors display name to a variable.

Post by Murble »

Alright, I got that working.
But, in the dialogue text if I try using [var=Actor] it uses the old display name. I assume that it is just pulling that out of the cached data.
I can do

Code: Select all

[lua( Actor["Player"].Display_Name )]
to make it display the new updated name, but that is kind of annoying.
Is there a way to update the cache during runtime?
Last edited by Murble on Mon Jul 20, 2020 8:01 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Setting actors display name to a variable.

Post by Tony Li »

Hi,

In the same Script field where you call the Lua function to change the Display Name, you can also set Variable["Actor"] to the same value.
Post Reply