Hello, I have quest entry number variables for my conversations.
I want to use these numbers in a scoreboard menu while game is going on or ended. Scoreboard menu will be in an another scene, which doesn't have a dialogue manager.
How can i pull that data from dialogue manager?
Thanks guys
Pulling Quest Entry Variable Data to Use in Scoreboard
Re: Pulling Quest Entry Variable Data to Use in Scoreboard
Hi,
Unless you changed the Dialogue Manager's Other Settings > Don't Destroy On Load, it will continue to exist when you change from a scene with the Dialogue Manager to your scoreboard menu scene. This means your quest data will still be available.
You can use the QuestLog class to get most quest information. If you need to get information that is not available through QuestLog, such as custom fields that you have defined, use the DialogueLua class.
Unless you changed the Dialogue Manager's Other Settings > Don't Destroy On Load, it will continue to exist when you change from a scene with the Dialogue Manager to your scoreboard menu scene. This means your quest data will still be available.
You can use the QuestLog class to get most quest information. If you need to get information that is not available through QuestLog, such as custom fields that you have defined, use the DialogueLua class.
Re: Pulling Quest Entry Variable Data to Use in Scoreboard
Hello i tried this script but it is giving error:Tony Li wrote: ↑Thu May 30, 2019 9:52 am Hi,
Unless you changed the Dialogue Manager's Other Settings > Don't Destroy On Load, it will continue to exist when you change from a scene with the Dialogue Manager to your scoreboard menu scene. This means your quest data will still be available.
You can use the QuestLog class to get most quest information. If you need to get information that is not available through QuestLog, such as custom fields that you have defined, use the DialogueLua class.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PixelCrushers;
using PixelCrushers.DialogueSystem;
public class Entries : MonoBehaviour
int entryResult;
static string PixelCrushers.DialogueSystem.QuestLog.CurrentQuestEntryState(string questName,
double entryNumber)
{
return entryResult;
}
}
Please help me to wirte the code Tony!:)
Re: Pulling Quest Entry Variable Data to Use in Scoreboard
Hi,
What information do you want to pull?
Please reply with a text description or a mock-up drawing of what information you would like to show in the scoreboard.
What information do you want to pull?
Please reply with a text description or a mock-up drawing of what information you would like to show in the scoreboard.
Re: Pulling Quest Entry Variable Data to Use in Scoreboard
I make a Riddle game. There are different scenes for different difficulties of the riddles. So i have multiple scenes with different dialogue managers.
Game is based on conversations:
A NPC guy is asking a riddle and the player is answering the riddle.
If the player gives correct answer my number typed quest entry variable "Correct Answers" increasing 1 with a quest entry on dialogue settings. Variable["Correct Answer"] = Variable["Correct Answer"] + 1
If player gives wrong answer to the riddle, my number typed quest entry variable "Wrong Answers" is increasing 1 with a quest entry on dialogue settings. Variable["Wrong Answer"] = Variable["Wrong Answer"] + 1
Quest names for correct answer is Hello Mr.Riddler and You're Riddled for wrong answer;
So i want to collect that data of correct answers and wrong answers of the players and show to the players in home scene when they press show score board button.
Lets say if i can manage to pull the current int value of Correct Numbers and pass it to a static int in update function, does it work? Can i use it globally? does it saved after quitting the game, exiting the scene etc, and do i need a get set method to pass the value?
many thanks,
Re: Pulling Quest Entry Variable Data to Use in Scoreboard
It's much easier if all of the Dialogue Managers use the same dialogue database.
Put a Dialogue Manager in the start scene and the score board scene, too. (Make sure they all point to the same dialogue database, and the default checkboxes are ticked: Don't Destroy On Load and Allow Only One Instance.)
In the Conditions and Script fields, you must replace blank space characters in the Variable[] part with underscores. So if the variable name in your dialogue database is "Correct Answer" then the Script field must be:
If you use the "..." button to access the dropdowns, it will generate the correct Conditions and Script text for you.
In scenes where you do not want to show the quest tracker HUD, add this script:
In the score board scene, use a script like below. You may need to modify it to suit your needs.
If you want to save the data between play sessions, set up the Save System components on the Dialogue Manager, and add an Auto Load Save component.
Put a Dialogue Manager in the start scene and the score board scene, too. (Make sure they all point to the same dialogue database, and the default checkboxes are ticked: Don't Destroy On Load and Allow Only One Instance.)
In the Conditions and Script fields, you must replace blank space characters in the Variable[] part with underscores. So if the variable name in your dialogue database is "Correct Answer" then the Script field must be:
Code: Select all
Variable["Correct_Answer"] = Variable["Correct_Answer"] + 1
In scenes where you do not want to show the quest tracker HUD, add this script:
HideQuestTrackerInThisScene.cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class HideQuestTrackerInThisScene : MonoBehaviour
{
void Start()
{
var tracker = FindObjectOfType<StandardUIQuestTracker>();
if (tracker != null) tracker.HideTracker();
}
void OnDestroy()
{
var tracker = FindObjectOfType<StandardUIQuestTracker>();
if (tracker != null) tracker.ShowTracker();
}
}
UpdateScoreboard.cs
Code: Select all
using UnityEngine;
using UnityEngine.UI;
using PixelCrushers.DialogueSystem;
public class UpdateScoreboard : MonoBehaviour
{
public Text numCorrectText; //<-- ASSIGN THESE IN INSPECTOR.
public Text numWrongText;
void Start()
{
numCorrectText.text = "Correct: " + DialogueLua.GetVariable("Correct Answer").asInt;
numWrongText.text = "Wrong: " + DialogueLua.GetVariable("Wrong Answer").asInt;
}
}