Page 1 of 1
Discover Name Example with variable name?
Posted: Thu Oct 29, 2020 7:49 pm
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.
Re: Discover Name Example with variable name?
Posted: Thu Oct 29, 2020 9:17 pm
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"])
Re: Discover Name Example with variable name?
Posted: Fri Oct 30, 2020 12:07 am
by zeroxpy
Hi Tony, thanks for your quick reply. This solves my problem nicely.
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.
Re: Discover Name Example with variable name?
Posted: Fri Oct 30, 2020 9:24 am
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#.