Link to another convo functionality from Script or Sequence fields?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Link to another convo functionality from Script or Sequence fields?

Post by Abelius »

Hi there,

I need to implement sub-conversations that will play "inside" other conversations.

For example, an NPC reacting to the attire of the MC with some small chat, and then continuing the normal main conversation flow.

The thing is, this will trigger in multiple conversations, not always the same one. So, when the sub-convo is done, it would be ideal to have a way to return to the original conversation (and a given entry ID) with just one node, not adding one for each origin.

However, the "Links To:" UI doesn't allow this, so I was wondering if there is a script or sequence command I could run to jump to another conversation and ID, keeping the Actor and Conversant info, ofc.

My plan right now is to use the PlayMaker "Jump To Entry" action, by calling an FSM that checks a couple variables (pre-saved Convo ID and Entry ID) when I want to return to the original one, but if there is something built in I'm not aware of, that already implements this functionality, that would be better.

Thanks.
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 22131
Joined: Thu Jul 18, 2013 1:27 pm

Re: Link to another convo functionality from Script or Sequence fields?

Post by Tony Li »

Hi,

You can use the conversation position stack. Briefly, you'll use the Lua function PushConversationPosition() in the Script field of some node in the main conversation before switching into the sub-conversation. Then use PopConversationPosition() at the end of the sub-conversation to return to the node that you previously pushed.
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: Link to another convo functionality from Script or Sequence fields?

Post by Abelius »

That looks very promising!

But I'm afraid I don't know how to use it properly. I've even managed to freeze Unity (good thing I use an auto-saver).

I've added the component to the manager:

Image

Then I have this structure in the main convo...:

Image

It goes to "Reaction due?", then onto "Go to FirstKayla"...:

Image

This is where I've put the Push command, then it links to the other conversation, which runs and I have this final node...:

Image
Image

If I leave it like this, it's stuck in that last entry without returning to the previous convo.

If I add a Continue(), Unity freezes.

And my guess is that it's not really frozen but in an infinite loop. Because it returns to the same node in the master convo and re-links again to the sub-convo (which won't trigger any dialogue the second time because I prevent that from happening with conditionals).

You said I should put the Push in a previous node before linking to the other convo (?)

But I don't understand the logic of that. If I do it, I'll still have a loop on my hands, as the stored position will be previous to the sub-convo link, and it'll go there again, and again...

That's why I've put both the Push and the link to the sub-convo in the same node, along with a second link to the next "return" node, thinking that it would pick the second link this time, but it doesn't.

Then I see this...:

Image

...and I wonder what it means "Follow up" entry. Is that the entry it would go to in normal circumstances? Because in that case, I guess that what I've actually stored was the destination convo+entry instead of the next node in the master convo, no?

How do I break this Catch-22 situation?
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 22131
Joined: Thu Jul 18, 2013 1:27 pm

Re: Link to another convo functionality from Script or Sequence fields?

Post by Tony Li »

Hi,

It may have to do with the Group node. I'm out of the office for a few hours so I can't test. Can you try adding a regular (non-Group) node and moving the PushConversationPosition() there? Or untick the Group checkbox and set the Sequence to Continue() so it behaves kind of like a pass-through group node.
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: Link to another convo functionality from Script or Sequence fields?

Post by Abelius »

I'm not using group nodes here. :?
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 22131
Joined: Thu Jul 18, 2013 1:27 pm

Re: Link to another convo functionality from Script or Sequence fields?

Post by Tony Li »

Sorry, I misread your screenshot. Understood, no group node.

Here's an example scene:

DS_ConversationStackExample_2023-04-08.unitypackage

The conversation is set up like this:

positionStackExample.png
positionStackExample.png (53.46 KiB) Viewed 757 times

In the last node of the New Hat conversation, the Script is: PopConversationPosition(), which returns back to <Delay Evaluation>.
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: Link to another convo functionality from Script or Sequence fields?

Post by Abelius »

Hmm, alright, now I get it. It's designed so it returns to the stored node. So we need conditionals in place after it, to avoid loops.

Not what I expected and needed, but the function works as advertised. :roll:

What I wanted is to continue the original conversation on the next node calling the sub-convo. But the question is, how DS will know which node is supposed to be the "next" one, no?

That's why I innocently put a second link on the calling node. But ofc it treats the node as normal and the first link is used again.

So, I've ended up using two variables to set that info on DS (master convo title and entry id of the next node), and then I call the Jump To Entry action on the returning node at the end of the sub-convo. It works, so I'm happy. :P

Thanks for the support!
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 22131
Joined: Thu Jul 18, 2013 1:27 pm

Re: Link to another convo functionality from Script or Sequence fields?

Post by Tony Li »

Glad to help!
Post Reply