Hey everyone, just wanted to start off by saying I’m really enjoying this plugin and it’s helping me build out the text adventure game I’ve always wanted to create.
At the moment I’m trying to build out an item inventory system using only text dialogues like the old Hideo Kojima game, Snatcher.
The player would be able to access this items menu from the main choice dialogue at any point.
So my idea was to build out a conversation with every item dialogue possible and have response branches for those items that are controlled by variables that determine wether the item has been acquired yet.
I’ve been able to link to this item conversation easily from my various character dialogues, but I am stuck at the point of returning to the previous conversation and dialogue entry.
My goal is to have a simple “BACK” option in the inventory conversation that links to the last conversation ID and entry. I attempted to code a couple of Lua commands to run in the “BACK” entry’s sequence that would help me reference it, but had trouble passing the CurrentConversationState required variables.
I saw in this post that you’re planning on implementing some actions for these:
viewtopic.php?f=3&t=1668
Was wondering if there was any current way to go about this?
Thanks again for all your work, this plugin rocks!
Linking back to the last conversation entry?
- pixelglitch
- Posts: 6
- Joined: Sun Sep 16, 2018 10:26 pm
- Location: Denver, CO
- Contact:
Re: Linking back to the last conversation entry?
Thanks for the compliments!
If you don't mind a little C#, you can add a script that uses some of the special conversation messages, specifically OnConversationLine and OnLinkedConversationStart.
In OnConversationLine, record the current conversation ID and entry ID.
In OnLinkedConversationStart, save the current conversation and entry IDs as the previous conversation.
Register a Lua function that you can call in the BACK option to return to the previous conversation.
Here's an example: BackConversationExample_2018-09-21.unitypackage
And here's the script in case you don't want to download the example:
If you don't mind a little C#, you can add a script that uses some of the special conversation messages, specifically OnConversationLine and OnLinkedConversationStart.
In OnConversationLine, record the current conversation ID and entry ID.
In OnLinkedConversationStart, save the current conversation and entry IDs as the previous conversation.
Register a Lua function that you can call in the BACK option to return to the previous conversation.
Here's an example: BackConversationExample_2018-09-21.unitypackage
And here's the script in case you don't want to download the example:
BackConversationExample.cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class BackConversationExample : MonoBehaviour
{
// (Public just so we can see in inspector for debugging:)
public string previousConversation;
public int previousEntryID;
public string currentConversation;
public int currentEntryID;
void OnEnable()
{
// Call this Lua function in an entry's Script field to return to the previous conversation:
Lua.RegisterFunction("Back", this, SymbolExtensions.GetMethodInfo(() => Back()));
}
void OnDisable()
{
Lua.UnregisterFunction("Back");
}
public void Back()
{
// Stop the current conversation and start the previous one:
DialogueManager.StopConversation();
DialogueManager.StartConversation(previousConversation, DialogueManager.currentActor, DialogueManager.currentConversant, previousEntryID);
}
private void OnConversationLine(Subtitle subtitle)
{
// When an NPC speaks, record the current conversation:
if (subtitle.speakerInfo.isNPC)
{
currentConversation = DialogueManager.masterDatabase.GetConversation(subtitle.dialogueEntry.conversationID).Title;
currentEntryID = subtitle.dialogueEntry.id;
}
}
private void OnLinkedConversationStart(Transform actor)
{
// When we cross conversations, record the previous conversation:
previousConversation = currentConversation;
previousEntryID = currentEntryID;
}
}
- pixelglitch
- Posts: 6
- Joined: Sun Sep 16, 2018 10:26 pm
- Location: Denver, CO
- Contact:
Re: Linking back to the last conversation entry?
Sorry for my delay on this, just tested and it's working perfectly.
Was not expecting such a fleshed out answer, thanks so much for your help with this Toni!
Was not expecting such a fleshed out answer, thanks so much for your help with this Toni!
Re: Linking back to the last conversation entry?
Happy to help!