Page 1 of 1

QuestLog.GetQuestTitle is not returning display name

Posted: Sat Mar 26, 2022 12:00 am
by irongamer
I have a question about QuestLog.GetQuestTitle and the "Use Display Name" toggle in the quest/item area. I'm using the special quest names to sort them into groups in the dialogue DB UI, so those names are not desired for display in the game quest UI.

QuestLog.GetQuestTitle is falling back on the default name field as the "Display Name" field appears to be returning nil by Lua. I followed the debugger down to GetTableField and the luTable element appears to be correct but the Display Name fields is not in the dictionary list and I think that is why it is returning nil.

It appears that The Display Name field (text) added when checking the "Use Display Name" is not in the dictionary.

Dialogue Database - The Quest
  • Name: TutorialForest-TrollProblem
  • Use Display Name: True (checked)
  • Display Name: Another troll... (also tried it without the ...)

Code to pull up the quest title

Code: Select all

string questTitle = QuestLog.GetQuestTitle("TutorialForest-TrollProblem");
Result
"TutorialForest-TrollProblem"

I was expecting the display name "Another troll..." instead.

How to fix?

Do I need to add "Display Name" to the quest template? When "Use Display Name" is checked it adds a display name field (text) to the DB UI. Does the "Display Name" field need to be set to localization instead of text? I ask that because the GetQuestTitle function is using the following:

Code: Select all

var title = DialogueLua.GetLocalizedQuestField(questName, "Display Name").asString;
I also tried accessing the field like this:

Code: Select all

DialogueLua.GetLocalizedQuestField("TutorialForest-TrollProblem", "Display Name").asString;
That returns an empty string.

Re: QuestLog.GetQuestTitle is not returning display name

Posted: Sat Mar 26, 2022 9:48 am
by Tony Li
Hi,

QuestLog.GetQuestTitle() should return the quest's Display Name if it has a Display Name. If not, it will return the quest's Name.

Can you check if maybe an older version of your dialogue database is assigned to the Dialogue Manager's Initial Database field?

Or maybe you have duplicate quests named "TutorialForest-TrollProblem" in your database and one of them doesn't have a Display Name?

Re: QuestLog.GetQuestTitle is not returning display name

Posted: Sun Mar 27, 2022 2:19 am
by irongamer
Can you check if maybe an older version of your dialogue database is assigned to the Dialogue Manager's Initial Database field?
Ah! My fault. It was related to this but was due to a save state being loaded. I assume loading a saved state uses only the saved state and doesn't merge new fields? I was making changes to dialogue and those were coming through but had not thought about save/load states affecting the quest content different than the dialogue trees.

Loading the db

Code: Select all

PixelCrushers.DialogueSystem.PersistentDataManager.ApplySaveData(loadedPlayerState.pixelCrusherSave);
I'm saving the db inside another object because most of the game save state stuff is already handled. I started a new game and display name is working as expected.

Re: QuestLog.GetQuestTitle is not returning display name

Posted: Sun Mar 27, 2022 9:12 am
by Tony Li
Hi,

If you tick the Dialogue Manager's Persistent Data Settings > Initialize New Variables checkbox, loading a saved game will add new quests that weren't in the original save. However, it won't update fields in existing quests that were already recorded in the save, since it's possible that the game intentionally changed a field value during runtime. You may need to add an extra step that applies your new changes to quests that were already in the save.

Re: QuestLog.GetQuestTitle is not returning display name

Posted: Sun Mar 27, 2022 10:24 pm
by irongamer
Yeah, "Initialize New Variables" was already checked. There shouldn't be any more surprise fields as most of the game's other quest and loot systems are referenced in already with another field. Shouldn't need any db compare code, I hope, but is there functionality for loading a saved db and comparing it to the "master" version? Or is there a best practice for doing something like that?

Thanks all the help, you folks are awesome!

Re: QuestLog.GetQuestTitle is not returning display name

Posted: Mon Mar 28, 2022 8:37 am
by Tony Li
There's no built-in functionality for that. Different devs might want to compare different things.

The save system does, however, let you associate a version number with saved games. You can set the version number on the Save System component. When loading a saved game, you can check the version number and make accommodations for older saved games. The current saved game data's version number is in SaveSystem.currentSavedGameData.version (int).