Save in TXT file
Save in TXT file
Hey! It's me again!
My project is basically to collect the information from NPCs. The information will be displayed in Quest Journal.
I wish to save the information that the player has collected into .txt file.
Is there any function that I can use to save information?
My project is basically to collect the information from NPCs. The information will be displayed in Quest Journal.
I wish to save the information that the player has collected into .txt file.
Is there any function that I can use to save information?
Re: Save in TXT file
Hi,
You basically want to save the contents of the player's quest journal UI to a text file, correct?
If so, there isn't a single function to do this. However, you can still get the content with some API calls. Roughly, something like this will get the content:
You basically want to save the contents of the player's quest journal UI to a text file, correct?
If so, there isn't a single function to do this. However, you can still get the content with some API calls. Roughly, something like this will get the content:
Code: Select all
var questJournal = QuestMachine.GetQuestJournal();
var txt = string.Empty
foreach (var quest in questJournal.questList)
{
txt += quest.title + " (" + quest.GetState() + ")\n";
contents = quest.GetContentList(QuestContentCategory.Journal);
foreach (var content in contents)
{
txt += content.runtimeText + "\n";
}
}
System.IO.File.WriteAllText("filename.txt", txt);
Re: Save in TXT file
Hey Tony!
The code is worked. But the output displayed are repeated. How can I avoid this problem?
The code is worked. But the output displayed are repeated. How can I avoid this problem?
Re: Save in TXT file
It should basically be the same output that appears in the quest journal UI. The difference is that the TXT outputs all quests in the player's quest journal, including all inactive, active, and completed quests.
What repeated information do you see?
What repeated information do you see?
Re: Save in TXT file
Oh, I made a mistake in my code. And yes, now the information is displayed as same as the one shown in Quest Journal.
I realise that when the quest is successful, the information is replaced by the quest state. But I want to keep the information after the quest is completed (doesn't matter it's failed or successful).
I realise that when the quest is successful, the information is replaced by the quest state. But I want to keep the information after the quest is completed (doesn't matter it's failed or successful).
Re: Save in TXT file
The GetContentList method gets the content for the current quest state. If you want the same text to appear for the success and failure states, currently you need to put the same text in those states. If you use a text table, you can point them both to the same field in the text table.
Re: Save in TXT file
The information, that I want to display in the text file, is the option player chooses in the game. So basically not all information will come out in the text file. And I'm not using text table, so yea.
Re: Save in TXT file
Hi,
Are you talking about options the player chooses during a Dialogue System conversation? Or some other option?
Are you talking about options the player chooses during a Dialogue System conversation? Or some other option?
Re: Save in TXT file
Yes, the options in the Dialogue System.
Re: Save in TXT file
Hi,
Dialogue System conversations are not stored in Quest Machine, so you will need to do something different for them. You can do something like the Dialogue System's ConversationLogger.cs script. This script normally logs the conversation to the Console window / output log. But you can record it in your own place, too.
Dialogue System conversations are not stored in Quest Machine, so you will need to do something different for them. You can do something like the Dialogue System's ConversationLogger.cs script. This script normally logs the conversation to the Console window / output log. But you can record it in your own place, too.