[Solved] Getting some context in conditions

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Iegor
Posts: 5
Joined: Thu Jun 09, 2016 11:33 am

[Solved] Getting some context in conditions

Post by Iegor »

Hi!
I'm thinking of better conversation structuring, since conversation/quest tables are getting bit out of hand in terms of size. What I need is to automate some condition checks.

For instance I assign a custom field of "Item" type to conversation to hold relative quest name.

Then I want to create formal conversation template -
Conversation having dialogue entry for "unassigned","active", "success","failed" quest states.
Ordinary we have to do checks in these entries like this GetCurrentQuestState("QuestName") == "unassigned"

But since we have a quest field in conversation object, how can I get current evaluated Conversation id?
To do the following: GetCurrentQuestState(Conversations[ID].quest) == "unassigned"
How can i get this ID?

This will be very helpful for restructuring dialogues based on quests.

Best regards,
Iegor
Last edited by Iegor on Mon Jun 13, 2016 10:48 am, edited 1 time in total.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Getting some context in conditions

Post by Tony Li »

Hi Iegor,

You could set a Lua variable "ID" in a script attached to the Dialogue Manager. Something like:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class SetConversationID : MonoBehaviour {
    void OnConversationStart(Transform actor) {
        Lua.Run("ID = " + DialogueManager.MasterDatabase.GetConversation(DialogueManager.LastConversationStarted).id);
    }
}
Then use it like this in your Conditions field:

Code: Select all

GetCurrentQuestState(Conversations[ID].quest) == "unassigned"
Iegor
Posts: 5
Joined: Thu Jun 09, 2016 11:33 am

Re: Getting some context in conditions

Post by Iegor »

Yes thought of something like this, but this will not help when I check entry for validity right?

Using

Code: Select all

DialogueManager.ConversationHasValidEntry ();
So, for example, standard conversation trigger won't work, because ID variable is not set correctly when it checks?

Also I sometimes check for valid dialogue lines to put a quest mark over npc, this happens without starting conversation.

Thing I want to achieve is a method for checking quest state in conversation that is linked to quest :idea: , without entering quest name to condition script.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Getting some context in conditions

Post by Tony Li »

Try this instead:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class SetConversationID : MonoBehaviour {
    void OnPrepareConversationLine(DialogueEntry dialogueEntry) {
        Lua.Run("ID = " + dialogueEntry.conversationID);
    }
} 
The Dialogue System calls OnPrepareConversationLine(dialogueEntry) before evaluating links in ConversationHasValidEntry.
Iegor
Posts: 5
Joined: Thu Jun 09, 2016 11:33 am

Re: Getting some context in conditions

Post by Iegor »

Hi!

Thank you for your help, it worked, I now use simple checks like this :

Code: Select all

CurrentQuestState(ConversationQuestName) == "success"
And state changes like this:

Code: Select all

SetQuestState(ConversationQuestName,"done");
And effectively link conversations to specific quests!

Kind regards,
Iegor
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: [Solved] Getting some context in conditions

Post by Tony Li »

Whew! I'm glad that worked. ;)
Post Reply