Discover Name Example with variable name?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
zeroxpy
Posts: 12
Joined: Tue Oct 20, 2020 10:50 pm

Discover Name Example with variable name?

Post by zeroxpy »

Hi, I saw your "Discover Name Example" which shows Player the NPC name after conversation. In this case, NPC has a fixed name. Is their any way to change NPC's name if it is variable?

In my case, I have an input text field where I can key in NPC's name. I am trying to name my NPC using the string that I key in.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Discover Name Example with variable name?

Post by Tony Li »

Hi,

Yes. Use the same Lua function and specify the variable.

In the original example, the dialogue entry has this Script:
  • Script: ChangeActorName("Mephistopheles", "Mephistopheles")
Let's say you used the TextInput() sequencer command to read the player's input into a variable named "NPC_Name". Then use this:
  • Script: ChangeActorName("Mephistopheles", Variable["NPC_Name"])
zeroxpy
Posts: 12
Joined: Tue Oct 20, 2020 10:50 pm

Re: Discover Name Example with variable name?

Post by zeroxpy »

Hi Tony, thanks for your quick reply. This solves my problem nicely. :lol: :lol: :lol:

It seems to me that the "script" used in Conversation under "Dialogue Entry" is very different compared to scripts used elsewhere in Unity. Can you let me know where I can learn more about its grammar and usage? Thank you.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Discover Name Example with variable name?

Post by Tony Li »

Hi,

The short answer is that the Dialogue System's Script and Conditions fields use a simple scripting language called Lua. You can read more about it here: Logic & Lua. In most cases, you don't have to type any Lua code. You can just click the "..." button and select what you want from dropdowns.

The longer answer is that the Dialogue System is fully compatible with an existing application called Chat Mapper that's widely used in the industry for writing interactive dialogue. Chat Mapper uses Lua, mainly because it's the most commonly used language for modding games. So, for full compatibility, the Dialogue System uses Lua. This also makes it easier for modders if you decide to add player modding to your game, since they're more likely to be familiar with Lua than C#.
Post Reply