How to add a string in a dialog?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Matty86
Posts: 1
Joined: Sat Jun 04, 2016 5:31 pm

How to add a string in a dialog?

Post by Matty86 »

So my question is very simple and I can't figure it out.

I want to write something like this using the dialogue system:

"Hello, my name is (MY_NAME) and I am (AGE) years old."

(My_NAME) and (AGE) are field inside actor, or variables in the dialogue system, or even variables inside a c# script.

How can I get achieve this with the dialogue system?

Thank you for your help
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add a string in a dialog?

Post by Tony Li »

Hi,

If MY_NAME and AGE are variables in the Dialogue System, use the [var=varName] tag:
  • Dialogue Text: ""Hello, my name is [var=MY_NAME] and I am [var=AGE] years old."
If they're fields inside an actor, use the [lua(code)] tag
  • Dialogue Text: ""Hello, my name is [lua( Actor["Player"].MY_NAME )] and I am [lua( Actor["Player"].AGE )] years old."
When a conversation starts, the Dialogue System automatically sets the variables "Actor" and "Conversant" to the names of the actor and conversant assigned to the conversation trigger. This means you can get fancier like this:
  • Dialogue Text: ""Hello, my name is [lua( Actor[Variable["Conversant"]].MY_NAME )] and I am [lua( Actor[Variable["Conversant"]].AGE )] years old."
If they're variables inside a C# script, register a C# method with Lua. For example, you could register functions called MyName() and MyAge(), or you could register a single general-purpose function called something like LookupValue():
  • Dialogue Text: ""Hello, my name is [lua( LookupValue("MY_NAME") )] and I am [lua( LookupValue("AGE") )] years old."
Post Reply