Page 1 of 1

How To: Show Variables and Actor Fields in Dialogue Text

Posted: Sun Nov 15, 2020 10:30 pm
by Tony Li
This post explains how to show variable values and actor field values in dialogue text.

Variables
To show variable values in dialogue text, use the [var=variable] markup tag. Example:
  • Dialogue Text: "Brrr! It's only [var=CurrentTemperature] degrees out today!"
When a conversation starts, the Dialogue System automatically sets four variables:
  • Variable["Actor"]: The display name of the character being used as the conversation's actor.
  • Variable["Conversant"]: The display name of the character being used as the conversation's conversant.
  • Variable["ActorIndex"]: The index into the Actor[] list for the actor, such as "Player" for the list element Actor["Player"].
  • Variable["ConversantIndex"]: The index into the Actor[] list for the conversant.
Note: If you've overridden the actors used by the current running instance of the conversation (see Character GameObject Assignments), the Actor and Conversant variables will reflect the display names of those characters. However, ActorIndex and ConversantIndex may reflect the actual actors assigned to the conversation in the dialogue database if the current actor or conversant is not represented by an actor in the database.

Actor Fields
(This also applies to Quest, Item, and Location fields.)

Use the [lua(code)] markup tag. For example, say the actor Timmy has a field named Age. You can do this:
  • Dialogue Text: "I'm [lua(Actor["Timmy"].Age)] years old."
If you don't know the actor ahead of time (for example, in conversations that are reusable by multiple characters), you can use the ActorIndex and ConversantIndex variables mentioned above. For example:
  • Dialogue Text: "My name is [var=Conversant]. I'm [lua(Actor[Variable["ConversantIndex"]].Age)] years old."