Saving conversation state, interrupting and resuming from the same entry later
Posted: Thu Sep 14, 2023 3:28 pm
Hi,
I am currently working on a system where I want to pause my currently active conversation and resume it at a later point. I know the DialogueManager class has a Pause function, but I believe I won't be able to use that. This is because it is possible that I have to run a short, different conversation while the main one is interrupted.
So the flow I want to achieve is this:
I feel like I nearly have it solved, but I'm missing something and I may be overlooking a better way to do this. This is what I do currently:
Below is the test conversation I'm using. Entry 11 is the one that should interrupt the conversation (note the script on it), in the final version it wouldn't have any dialogue text. Entry 12 is where the conversation should resume (pink = PC, grey = NPC).
Code snippet for stopping conversation (this is triggered from the Lua script in entry 11):
Code snippet for restarting conversation:
The problem is that _lastConversationState actually saves entry 10, not 11, even though this code is triggered from the script in entry 11. That causes PCAutoReponse to be null. I've tried to run through the chain of linked entries to get to 12 eventually, but I get stuck doing _lastConversationState.FirstNPCResponse.destinationEntry and then can't figure out how to get the follow-up entry from that. But that's already a workaround, if I were saving the correct state (entry 11) I wouldn't need to do this and my code should work, I think.
Sorry for the long post, I've tried to describe the issue in as much detail as possible.
I am currently working on a system where I want to pause my currently active conversation and resume it at a later point. I know the DialogueManager class has a Pause function, but I believe I won't be able to use that. This is because it is possible that I have to run a short, different conversation while the main one is interrupted.
So the flow I want to achieve is this:
- Start conversation A
- Stop conversation A and fully hide the DSFU UI. Remember the current state (dialogue entry id). Some other UI is shown in the mean time, I have my own scripts to handle this
- Start conversation B and run through it fully
- Restart conversation A from the entry following the one where it was interrupted
I feel like I nearly have it solved, but I'm missing something and I may be overlooking a better way to do this. This is what I do currently:
- DialogueManager.StartConversation() to start conversation A
- Save DialogueManager.lastConversationID and DialogueManager.currentConversationState in two variables when interrupting
- DialogueManager.StartConversation() to start conversation B
- DialogueManager.StartConversation() to start conversation A again, with the previously saved conversation id as a parameter.
Below is the test conversation I'm using. Entry 11 is the one that should interrupt the conversation (note the script on it), in the final version it wouldn't have any dialogue text. Entry 12 is where the conversation should resume (pink = PC, grey = NPC).
Code snippet for stopping conversation (this is triggered from the Lua script in entry 11):
Code: Select all
//save conversation state
_lastConversationState = DialogueManager.currentConversationState;
_lastConversationStarted = DialogueManager.lastConversationStarted;
DialogueManager.StopConversation();
Code: Select all
DialogueManager.StartConversation( _lastConversationStarted, null, null, _lastConversationState.PCAutoResponse.destinationEntry.id );
Sorry for the long post, I've tried to describe the issue in as much detail as possible.