Hey! I want to add quotes from conversations to a List<string> in a separate script. I was planning on using the "Dialogue Text" field under the dialogue entry, but I can't find a good way of accessing it.
Basically I want the loop to go as such:
-player talks to character
-player gets to specific line of dialogue
-that line is saved to a list of special quotes
I feel like there's a lua command I'm missing or something. I'll take any help.
Accessing Dialogue Entry Fields
Re: Accessing Dialogue Entry Fields
Hi,
You could use a script like the one below. It registers a Lua function RecordQuote(). Since dialogue entry Script fields run before OnConversationLine, it sets a bool so OnConversationLine knows to add the line to the list.
You could use a script like the one below. It registers a Lua function RecordQuote(). Since dialogue entry Script fields run before OnConversationLine, it sets a bool so OnConversationLine knows to add the line to the list.
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class Quotes : MonoBehaviour
{
bool quoteThisLine = false;
List<string> quotes = new List<string>();
void Awake()
{
Lua.RegisterFunction(nameof(RecordQuote), this, SymbolExtensions.GetMethodInfo(() => RecordQuote()));
}
void RecordQuote()
{
quoteThisLine = true;
}
void OnConversationLine(Subtitle subtitle)
{
if (quoteThisLine)
{
quotes.Add(subtitle.formattedText.text);
quoteThisLine = false;
}
}
}
-
- Posts: 4
- Joined: Mon Feb 07, 2022 5:15 pm
Re: Accessing Dialogue Entry Fields
This is great! thank you! I just have a small follow up question.
I understand that I would use the RecordQuote() function on dialogue nodes that I want to save to the quotes list.
I don't know where to implement the OnConversationLine(Subtitle subtitle) function. I also dont know what to pass into the subtitle variable.
Any extra help would be awesome. I'm super new to the dialogue system.
I understand that I would use the RecordQuote() function on dialogue nodes that I want to save to the quotes list.
I don't know where to implement the OnConversationLine(Subtitle subtitle) function. I also dont know what to pass into the subtitle variable.
Any extra help would be awesome. I'm super new to the dialogue system.
Re: Accessing Dialogue Entry Fields
Sorry, I completed skipped over that part, didn't I.
Put the script on your Dialogue Manager GameObject. If it's on the Dialogue Manager, the Dialogue System will automatically call the OnConversationLine() method.
Put the script on your Dialogue Manager GameObject. If it's on the Dialogue Manager, the Dialogue System will automatically call the OnConversationLine() method.