How to directly check the conversation end before linked conversation start and get it's title?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
shortlin
Posts: 73
Joined: Wed Jun 03, 2020 1:52 am

How to directly check the conversation end before linked conversation start and get it's title?

Post by shortlin »

I used two conversation in one masterbase.and then I use conversation 1's node's end to link the other converstaion's Start.

I would like to know when the conversation 1's node end happen and get the title to do somthing.

Are there one direct way to get that?

I had a idea to deal that,such like using dialugue system event's "OnConversationLineEnd "to get every ConversationState,and then in "OnLinkedConversationStart" to get last conversation.

code is like :

Code: Select all

PixelCrushers.DialogueSystem.ConversationState[] cArray = new PixelCrushers.DialogueSystem.ConversationState[2];
int cArrayCount=0;
in OnConversationLineEnd

Code: Select all

        cArray[cArrayCount%2] =PixelCrushers.DialogueSystem.DialogueManager.CurrentConversationState;

        cArrayCount++;
in OnLinkedConversationStart

Code: Select all

        int lastIndex=0;
        if(cArrayCount % 2==0)
        {
            lastIndex=1;
        }
        	Debug.Log(PixelCrushers.DialogueSystem.DialogueManager.MasterDatabase.GetConversation(cArray[lastIndex].subtitle.dialogueEntry.conversationID).Title);
It could get last conversation's title and just late one line conversation to do something.But that's not realy what I want.I want to get the end before the linked conversation start.
Are there one better way to get that?
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to directly check the conversation end before linked conversation start and get it's title?

Post by Tony Li »

Hi,

I'm not 100% clear on what you want to do. But I think you could do something like this:

Code: Select all

public class DoSomethingOnConversationChange : MonoBehaviour
{
    DialogueEntry previousEntry;
    
    void OnConversationStart(Transform actor)
    {
        previousEntry = null;
    }
    
    void OnPrepareConversationLine(DialogueEntry upcomingEntry)
    {
        if (previousEntry != null && previousEntry.conversationID != upcomingEntry.conversationID)
        {
            // Will link to new conversation. Do your thing here.
        }
        previousEntry = upcomingEntry;
    }
}
shortlin
Posts: 73
Joined: Wed Jun 03, 2020 1:52 am

Re: How to directly check the conversation end before linked conversation start and get it's title?

Post by shortlin »

Sorry to my poor English.
Thanks to your answer to let my solution has a better way.
But I mean..
sshot-2020-08-05-[10-49-28].png
sshot-2020-08-05-[10-49-28].png (10.67 KiB) Viewed 467 times
left blue node is in conversation 10005,I linked it to conversation 10008''s start node.

I want to do something in this blue node with it's conversation title[10005](It's not only one conversation like this,so I just used OnLinkedConversationStart Event to do something what I want to do).I thought maybe there are some way could let me directly call the node event. But I did not find this event,so I just had an idea was getting every state to memory the previousEntry in every node event.And then I used OnLinkedConversationStart to use the previousEntry's tile let me use its title to do something .But this is not really good way to solve my origin problem.
Last edited by shortlin on Tue Aug 04, 2020 11:34 pm, edited 2 times in total.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to directly check the conversation end before linked conversation start and get it's title?

Post by Tony Li »

Can you use the blue node's Sequence or Script field?

In the Sequence field, you can use sequencer commands. More info: Sequences, Tutorials

In the Script field, you can use Lua expressions. More info: Lua
shortlin
Posts: 73
Joined: Wed Jun 03, 2020 1:52 am

Re: How to directly check the conversation end before linked conversation start and get it's title?

Post by shortlin »

I can use Lua function.so I guess you you want me write the function in that node,that I could really get the title directly.
But I will not be responsible for the conversation job.That means, I should tell the guy who will do this job to copy the function code in the Linked conversation nodes.

m...maybe it's the better way if I want my code happen in right time.

But I preferred using Dialogue System Event,just because I use UnityAction to add the event Listener to do different situation.So if I want to use this kind solution,maybe I should use original method.Thank you.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to directly check the conversation end before linked conversation start and get it's title?

Post by Tony Li »

Sounds good. If you run into any issues or have further questions, just let me know.
Post Reply