Page 1 of 1

Ink Integration: Using the Conversation diagrams

Posted: Thu Dec 23, 2021 7:41 am
by Strig
Hello. I've been using both DS and Ink on different projects, but recently I decided to look into the integration.

Oneof the main reasons for me looking into it is that Ink can get... a bit chaotic at times, especially with long conversations or NPCs that have multiple dialogue trees. I was wondering if I could use it in conjunction with Dialogue System's Conversation diagrams. The nodes make it very easy to understand the flow, but writing the lines themselves in ink has become more comfortable for me. Is there any way I can invoke an ink script from a Conversation tree and then assign that Conversation tree to an NPC, for example?

Re: Ink Integration: Using the Conversation diagrams

Posted: Thu Dec 23, 2021 8:31 am
by Tony Li
Hi,

Ink is the one tool that works so differently from node-based dialogue trees that the integration doesn't even attempt to translate Ink content into a Dialogue System conversation tree.

However, you can still assign a Dialogue System Ink Trigger to an NPC. It's just like a regular Dialogue System Trigger -- with Conditions, extra Actions you can run, etc. -- except you can select an Ink story or knot to play.

I think it should also be possible to write a regular Dialogue System conversation tree and set it up to link to an Ink conversation. I haven't set up an example of this yet. But if that's something you need to do, let me know and I can look into what it would entail.

Re: Ink Integration: Using the Conversation diagrams

Posted: Thu Dec 23, 2021 12:52 pm
by Strig
Thanks for the quick response, as always!

Yeah, seeing the full dialogue tree and performing global quest/variable checks through DS is great, so starting up Inks through the dialogue tree itself could be a huge time-saver, while also keeping up the writing centralized and organized in a small number of ink documents.

If you could look into it, it would be a big help indeed! Correct me if I'm wrong, but I'm assuming this would probably be resolved with a node (containing no Dialogue Text) that calls the Ink via Events?

Maybe I could input the full path of Ink -> Knot -> Stitch, if necessary? I saw the Ink Trigger has one such option.

Re: Ink Integration: Using the Conversation diagrams

Posted: Thu Dec 23, 2021 10:07 pm
by Tony Li
This may or may not fit your needs:

LinkToInk_Test_2021-12-23.unitypackage

The scene (Test Link To Ink) starts a regular node-based Dialogue System conversation on start. The last node of the conversation calls a custom method in its Script field:

Code: Select all

LinkToInk("TheIntercept.admitted_to_something")
I wrote a small script called LinkToInkManager that makes the LinkToInk() method available to Lua. It accepts an Ink story name, optionally followed by a dot ( . ) and a knot name. This test scene links to TheIntercept's admitted_to_something knot.

The LinkToInk() method stores this link info. When the current conversation ends, it checks if there's any stored link info. If so, it starts the corresponding Ink story.
LinkToInkManager.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
using PixelCrushers.DialogueSystem.InkSupport;

public class LinkToInkManager : MonoBehaviour
{
    private string link;

    private void Awake()
    {
        Lua.RegisterFunction(nameof(LinkToInk), this, SymbolExtensions.GetMethodInfo(() => LinkToInk(string.Empty)));
    }

    public void LinkToInk(string link)
    {
        this.link = link;
    }

    private void OnConversationEnd(Transform actor)
    {
        if (!string.IsNullOrEmpty(link))
        {
            int pos = link.IndexOf(".");
            if (pos == -1)
            {
                DialogueSystemInkIntegration.SetConversationStartingPoint("");
            }
            else
            {
                string startingPoint = link.Substring(pos + 1);
                link = link.Substring(0, pos);
                DialogueSystemInkIntegration.SetConversationStartingPoint(startingPoint);
            }
            DialogueManager.StartConversation(link);
            link = string.Empty;
        }
    }
}