Page 1 of 1

Setting actors display name to a variable.

Posted: Wed Jul 15, 2020 8:36 pm
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"]

Re: Setting actors display name to a variable.

Posted: Wed Jul 15, 2020 8:54 pm
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.

Re: Setting actors display name to a variable.

Posted: Wed Jul 15, 2020 10:29 pm
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?

Re: Setting actors display name to a variable.

Posted: Thu Jul 16, 2020 8:24 am
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.