Page 1 of 1

How to add a string in a dialog?

Posted: Sat Jun 04, 2016 5:40 pm
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

Re: How to add a string in a dialog?

Posted: Sun Jun 05, 2016 12:21 am
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."