I've been trying to find the best way to go about about displaying Actor Names (Or additional Fields), Locations names (or Additional fields) .. Variables .. variable values etc. in the Dialogue Text.
Example:
A Shop Keeper is asking the Player:
Welcome, (Rich Text Bold)(Player's name), to (Location name)!
We currently have (Item stock variable) (Item Name) on sale for (Addition field price) each!
Sorry if the answer for this is really easy to find, because I am having some problems finding some examples to work off of in the documentation.
Actor Names / Items / Locations in Dialogue Text
Re: Actor Names / Items / Locations in Dialogue Text
Hi,
For the player's and conversant's (NPC's) display names, you can use the [var=Actor] and [var=Conversant] markup tags. You can use [var=variable] for any other variables, too. When a conversation starts, it sets four variables:
Example:
You can also manipulate the entire subtitle text before it's display if you want. To do that, add a script with an OnConversationLine method to the Dialogue Manager or one of the conversation participants. Example:
For the player's and conversant's (NPC's) display names, you can use the [var=Actor] and [var=Conversant] markup tags. You can use [var=variable] for any other variables, too. When a conversation starts, it sets four variables:
- Variable["Actor"]: Display name of the conversation's actor.
- Variable["ActorIndex"]: Index in the Actor[] Lua table (e.g., "Player" in Actor["Player"]).
- Variable["Conversant"]: Display name of the conversation's conversant.
- Variable["ConversantIndex"]: Index in the Actor[] Lua table of the conversant (e.g., "Bob" in Actor["Bob"] if Bob is the conversant).
Code: Select all
DialogueLua.SetVariable("ItemStock", 99);
DialogueLua.SetVariable("ItemName", "Red Balloons");
DialogueLua.SetVariable("FieldPrice", "1 gold");
- Dialogue Text: "We currently have [var=ItemStock] [var=ItemName] on sale for [var=FieldPrice] each!"
Example:
- Dialogue Text: "Welcome, <b>[var=Actor]</b>m to [lua(Actor[Variable["ConversantIndex"]].ShopName)]!
- Dialogue Text: "Nice to see a visitor from [lua(GetPlayerHometown())]."
You can also manipulate the entire subtitle text before it's display if you want. To do that, add a script with an OnConversationLine method to the Dialogue Manager or one of the conversation participants. Example:
Code: Select all
void OnConversationLine(Subtitle subtitle)
{
// Replace any instances of "<weather>" with the return value of some function named GetWeather():
subtitle.formattedText.text = subtitle.formattedText.text.Replace("<weather>", GetWeather());
}